Items

An item record holds the following information:

  • sales_account_id
  • description
  • tags
  • linked_children
  • is_discontinued
  • compound_children
  • name
  • purchase_account_id
  • pricing
  • disposition
  • is_hidden
  • id
  • categories
  • is_stock

Getting Items

GET (/api/v2/stock/items/:id()

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/stock/items/4     -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/stock/items/4';
$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/stock/items/4',
                         auth=('<username>', '<password>'))

print response.json

Example response:

{
    "sales_account_id": 2,
    "description": "One can sit on it",
    "tags": null,
    "linked_children": [],
    "is_discontinued": false,
    "compound_children": [],
    "name": "Chair",
    "purchase_account_id": 1,
    "pricing": [],
    "disposition": "normal",
    "is_hidden": false,
    "id": 4,
    "categories": [],
    "is_stock": false
}

Getting more than one item

GET (/api/v2/stock/items()

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

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

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/stock/items';
$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/stock/items',
                         auth=('<username>', '<password>'))

print response.json

Example response:

[
    {
        "sales_account_id": 2,
        "description": "One can sit on it",
        "tags": null,
        "linked_children": [],
        "is_discontinued": false,
        "compound_children": [],
        "name": "Chair",
        "purchase_account_id": 1,
        "pricing": [],
        "disposition": "normal",
        "is_hidden": false,
        "id": 2,
        "categories": [],
        "is_stock": false
    },
    {
        "sales_account_id": 2,
        "description": "One can write with it",
        "tags": null,
        "linked_children": [],
        "is_discontinued": false,
        "compound_children": [],
        "name": "Pen",
        "purchase_account_id": 1,
        "pricing": [],
        "disposition": "normal",
        "is_hidden": false,
        "id": 3,
        "categories": [],
        "is_stock": true
    }
]

Filtering

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

Creating Items

POST (/api/v2/stock/items()

Required fields:

  • purchase_account_id
  • sales_account_id
  • name
  • description
  • statuscode 200

    no error

  • statuscode 404

    could not create

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/stock/items     -H "Content-Type: application/json"     -k -u (login):(password)     -X POST     -d '{"purchase_account_id": 1, "sales_account_id": 2, "name": "Chair", "disposition": "normal", "description": "One can sit on it"}'

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/stock/items';
$data = array("purchase_account_id" => 1, "sales_account_id" => 2, "name" => u'Chair', "disposition" => u'normal', "description" => u'One can sit on it');
$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'purchase_account_id': 1, u'sales_account_id': 2, u'name': u'Chair', u'disposition': u'normal', u'description': u'One can sit on it'}

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

print response.json

Example response:

{
    "sales_account_id": 2,
    "description": "One can sit on it",
    "tags": null,
    "linked_children": [],
    "is_discontinued": false,
    "compound_children": [],
    "name": "Chair",
    "purchase_account_id": 1,
    "pricing": [],
    "disposition": "normal",
    "is_hidden": false,
    "id": 4,
    "categories": [],
    "is_stock": false
}

Updating Items

PUT (/api/v2/stock/items/(int: id)

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

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

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/stock/items/6';
$data = array("name" => u'My new value for name');
$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'name': u'My new value for name'}

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

print response.json

Example response:

{
    "sales_account_id": 2,
    "description": "One can sit on it",
    "tags": null,
    "linked_children": [],
    "is_discontinued": false,
    "compound_children": [],
    "name": "My new value for name",
    "purchase_account_id": 1,
    "pricing": [],
    "disposition": "normal",
    "is_hidden": false,
    "id": 6,
    "categories": [],
    "is_stock": false
}

Deleting Items

DELETE (/api/v2/stock/items/(int: id)

  • statuscode 200

    deleted entity successfully

  • statuscode 404

    entity not found

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/stock/items/1     -X DELETE -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/stock/items/1';
$options = array(
  'http' => array(
    'method'  => 'DELETE',
    '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.delete('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/stock/items/1',
                         auth=('<username>', '<password>'))

print response.json

Example response:

{
    "sales_account_id": 2,
    "description": "One can sit on it",
    "tags": null,
    "linked_children": [],
    "is_discontinued": false,
    "compound_children": [],
    "name": "Chair",
    "purchase_account_id": 1,
    "pricing": [],
    "disposition": "normal",
    "is_hidden": false,
    "id": 1,
    "categories": [],
    "is_stock": false
}