# Getting Started
# API Specification
All of the Ingrid services provide HTTP endpoints with Swagger specifications. These can be found at: In a typical integration with shipping selector widget you don't need to communicate with COS - SIW API should be used instead.
- SIW - https://api.ingrid.com/v1/siw/_/swagger.json
- COS - https://api.ingrid.com/v1/cos/_/swagger.json
- SOM - https://api.ingrid.com/v1/som/_/swagger.json
We have two environments that you can use:
https://api-stage.ingrid.com - is our staging and testing environment where you do all the testing and developing against
https://api.ingrid.com - is the production environment that you switch to when it’s time to go live
When you register with Ingrid you will receive an API token. This token must be send with every request in the Authorization HTTP header with the Bearer prefix followed by base64 encoded token. It will look something like this:
POST /v1/cos/session.create HTTP/1.1 Host: api.ingrid.com Authorization: Bearer ZjQ1Mjk0MDMyNTNhNDdmNmIyOTI3NDE2ODUzNTU0NmI= Content-Type: application/json
Every token is tied to specific environment thus you must use different tokens in staging or production environments.
The API token should be kept private and treated as a password. Hence all calls to our API should be done from the backend.
# Client Generation
Since Ingrid's API is built on top of OpenAPI specification you can use different tools to auto-generate API clients. Two that we recommend are Autorest that works great if you are on the Dotnet stack and OpenAPI Generator that works great for the rest of the programming languages.
Below are two simple examples that you can use as base to generate API clients.
Using Autorest generator to generate a C# client.
$ npm install -g autorest $ curl -o swagger.json https://api.ingrid.com/v1/siw/_/swagger.json $ autorest --csharp \ --clear-output-folder \ --input-file=swagger.json \ --override-client-name=SiwClient \ --namespace=Ingrid --add-credentials \ --output-folder=siw
Using OpenAPI Generator to generate a PHP client.
$ openapi-generator generate \ -i https://api.ingrid.com/v1/cos/_/swagger.json \ -g php \ -o siw
Hopefully, this is enough information to get you started.