Currencies

A currency record holds the following information:

  • code
  • name
  • symbol
  • html_code
  • id
  • is_base

Getting a Currency

GET (/api/v2/finance/currencies/:id()

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies/5     -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies/5';
$options = array(
  'http' => array(
    'method'  => 'GET',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

response = requests.get('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies/5',
                         auth=('<username>', '<password>'))

print response.json

Example response:

{
    "code": "SGD",
    "name": "Singapore Dollars",
    "symbol": "S$",
    "html_code": "S$",
    "id": 5,
    "is_base": false
}

Getting all Currencies

GET (/api/v2/finance/currencies()

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies     -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies';
$options = array(
  'http' => array(
    'method'  => 'GET',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

response = requests.get('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies',
                         auth=('<username>', '<password>'))

print response.json

Example response:

[
    {
        "code": "GBP",
        "name": "British Pound Sterling",
        "symbol": "\u00a3",
        "html_code": null,
        "id": 1,
        "is_base": true
    },
    {
        "code": "SGD",
        "name": "Singapore Dollars",
        "symbol": "S$",
        "html_code": "S$",
        "id": 3,
        "is_base": false
    },
    {
        "code": "CZK",
        "name": "Czech Koruna",
        "symbol": "Kc",
        "html_code": "Kc",
        "id": 4,
        "is_base": false
    }
]

Filtering

The results for a list of currencies can be filtered. See Filtering

Creating Currencies

POST (/api/v2/finance/currencies()

Required fields:

  • symbol
  • code
  • name
  • statuscode 200

    no error

  • statuscode 404

    could not create

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies     -H "Content-Type: application/json"     -k -u (login):(password)     -X POST     -d '{"html_code": "S$", "symbol": "S$", "code": "SGD", "name": "Singapore Dollars"}'

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies';
$data = array("html_code" => u'S$', "symbol" => u'S$', "code" => u'SGD', "name" => u'Singapore Dollars');
$options = array(
'http' => array(
'method'  => 'POST',
'content' => json_encode($data),
'header'=>  "Content-Type: application/json\r\n" .
            "Accept: application/json\r\n" .
            "Authorization: Basic " . base64_encode($credentials)
)
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

data = {u'html_code': u'S$', u'symbol': u'S$', u'code': u'SGD', u'name': u'Singapore Dollars'}

response = requests.post('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies',
                        data=json.dumps(data),
                        headers={'content-type': 'application/json'},
                        auth=('<username>', '<password>'))

print response.json

Example response:

{
    "code": "SGD",
    "name": "Singapore Dollars",
    "symbol": "S$",
    "html_code": "S$",
    "id": 5,
    "is_base": false
}

Updating Currencies

PUT (/api/v2/finance/currencies/(int: id)

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies/7     -H "Content-Type: application/json"     -k -u (login):(password)     -X PUT     -d '{"html_code": "My new value for html_code"}'

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies/7';
$data = array("html_code" => u'My new value for html_code');
$options = array(
'http' => array(
'method'  => 'PUT',
'content' => json_encode($data),
'header'=>  "Content-Type: application/json\r\n" .
            "Accept: application/json\r\n" .
            "Authorization: Basic " . base64_encode($credentials)
)
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

data = {u'html_code': u'My new value for html_code'}

response = requests.put('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/currencies/7',
                        data=json.dumps(data),
                        headers={'content-type': 'application/json'},
                        auth=('<username>', '<password>'))

print response.json

Example response:

{
    "code": "SGD",
    "name": "Singapore Dollars",
    "symbol": "S$",
    "html_code": "My new value for html_code",
    "id": 7,
    "is_base": false
}