Using the API
Introduction
Good to know
- BaseURL of the API is https://instantrestapi.com/api/
- The resource name can be anything that is accepted in a URL path (such as
invoices
orcustomers
, except in the website test playground - it is fixed toresources
). api/temporary-key
andapi/waitlist
endpoints are restricted and can only be used as described in the authentication section.- All resources created are scoped to an API key and can only be accessed using that specific key.
Creating a resource
Create a resource simply by POSTing a JSON object to the API URL followed by the name of your resource.
For example: to create a new invoice, send a POST request to the api/invoices
endpoint with a request body of the invoice object.
The following requirements must be met:
- Header
Content-Type
must beapplication/json
- Body must not be empty
- Body must be a valid JSON
- Body must contain
id
field - Body must be less than 1mb
Filtering & Searching
The API does not currently support filtering or searching of resources.
Schema
As long as the request body contains a valid JSON object, it will be accepted.
id
that is the unique identifier.The API does not currently support indexes or constraints.
Relationships
The API does not currently support any type of relationship between resources. Instead, you may choose one of the following 2 options.
1. Embedding related resources
The easiest strategy is to embed the related resources inside the top level resource. For example, you can embed a customer object or invoice lines in the invoice object as shown below:
Any time a customer or invoiceLine is updated, you must also update the whole invoice object to reflect the changes.
2. Embedding ids
Alternatively, you can embed references to other resources by id
if you keep track of relationsship updates client side.
For example, consider the below:
So if you request a DELETE
on api/invoicelines/1
, you must also do a PUT
on api/invoices/1
and remove the invoiceline from invoiceLineIds
array.
Subresources
The API does not currently support subresources. So for example, you cannot create/get an invoice line by sending a POST/GET request to api/invoices/1/invoicelines/1
.