Update API docs

This commit is contained in:
Hillel Coren 2017-03-17 16:16:25 +02:00
parent 3883c3d4f6
commit ec4b7b5023

View File

@ -15,30 +15,30 @@ Reading Data
Heres an example of reading the list of clients using cURL from the command line.
curl -X GET ninja.dev/api/v1/clients -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"
``curl -X GET ninja.dev/api/v1/clients -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
For invoices, quotes, tasks and payments simply change the object type. ie,
curl -X GET ninja.dev/api/v1/invoices -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"
``curl -X GET ninja.dev/api/v1/invoices -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
To load a single record specify the Id in the URL. Note: you can add ?invoice_number=0001 to search invoices by invoice number.
curl -X GET ninja.dev/api/v1/invoices/1 -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"
``curl -X GET ninja.dev/api/v1/invoices/1 -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
You can download a PDF using the following URL
curl -X GET ninja.dev/api/v1/download/1 -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"
``curl -X GET ninja.dev/api/v1/download/1 -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
Creating Data
"""""""""""""
Heres an example of creating a client. Note that email address is a property of the clients contact not the client itself.
curl -X POST ninja.dev/api/v1/clients -H "Content-Type:application/json" -d '{"name":"Client","contact":{"email":"test@gmail.com"}}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"
``curl -X POST ninja.dev/api/v1/clients -H "Content-Type:application/json" -d '{"name":"Client","contact":{"email":"test@gmail.com"}}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
You can also update a client by specifying a value for id. Next, heres an example of creating an invoice.
curl -X POST ninja.dev/api/v1/invoices -H "Content-Type:application/json" -d '{"client_id":"1", "invoice_items":[{"product_key": "ITEM", "notes":"Test", "cost":10, "qty":1}]}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"
``curl -X POST ninja.dev/api/v1/invoices -H "Content-Type:application/json" -d '{"client_id":"1", "invoice_items":[{"product_key": "ITEM", "notes":"Test", "cost":10, "qty":1}]}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
If the product_key is set and matches an existing record the product fields will be auto-populated. If the email field is set then well search for a matching client. If no matches are found a new client will be created. To email the invoice set email_invoice to true.
@ -49,19 +49,19 @@ Emailing Invoices
To email an invoice use the email_invoice command passing the id of the invoice.
curl -X POST ninja.dev/api/v1/email_invoice -H "Content-Type:application/json" -d '{"id":1}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"
``curl -X POST ninja.dev/api/v1/email_invoice -H "Content-Type:application/json" -d '{"id":1}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
Optional Settings
"""""""""""""""""
The following are optional query parameter settings:
- **serializer**: Either array (the default) or json. If json is selected the data is returned using the `JSON API <http://jsonapi.org/>`_ format.
- **include**: A comma-separated list of nested relationships to include.
- **client_id**: If set the results will be filtered by the client.
- **page**: The page number of results to return when the results are paginated.
- **per_page**: The number of results to return per page.
- **updated_at**: Timestamp used as a filter to only show recently updated records.
- **``serializer``**: Either array (the default) or json. If json is selected the data is returned using the `JSON API <http://jsonapi.org/>`_ format.
- **``include``**: A comma-separated list of nested relationships to include.
- **``client_id``**: If set the results will be filtered by the client.
- **``page``**: The page number of results to return when the results are paginated.
- **``per_page``**: The number of results to return per page.
- **``updated_at``**: Timestamp used as a filter to only show recently updated records.
Subscriptions
"""""""""""""