Corsali
  • Documentation Overview
  • Model API
    • cURL Example
    • Python Example
    • Errors
  • First Time User Guide
    • API Walkthrough
  • Authentication Keys
Powered by GitBook
On this page
  • Contents
  • Inputs to our REST API
  • URL Endpoint
  • Headers
  • Data (or body)
  • Run Through API Example
  • Interacting with a REST API on Your Own
  • Full Request Steps: cURL

Was this helpful?

First Time User Guide

An overview of interacting with a REST API

PreviousErrorsNextAPI Walkthrough

Last updated 3 years ago

Was this helpful?

Contents

  • (Optional)

Inputs to our REST API

There are 3 types of input to our API.

  • Headers

  • URL Endpoint

  • Data (or body)

URL Endpoint

The base URL is the starting point of the API you’re requesting from. The path specifies which model you are querying.

  • Base URL for our API: https://api.corsali.com/predict

  • Path for a specific model: {model_id}

  • Full url endpoint: https://api.corsali.com/predict/{model_id}

Headers

Headers provide authentication information as well as information on what kind of data will be passed in. Our API requires 3 headers:

Click on the link for each header type in order to understand the specifics about each header.

Data (or body)

The data contains the information that you will be sending to the API. The formatting of the input data will be different for different models. For formatting of the data:

  • Look under "Your Models" to see a list of models associated with your organization

  • Under each model is a "Request Input Data" page that explains the parameters and format of the input data

For most models the input format will be a JSON with a number of parameters passed in.

Run Through API Example

Interacting with a REST API on Your Own

Full Request Steps: cURL

Open Terminal

user ~ % 

It is also useful (although not necessary) to save your organization id and model ids somewhere they are easily accessible

Under "Your Models" > "Example Model" > "Request Input Data" find the "Example Input". Copy and pasted into a file and save it in your current path.

user ~ % ls
example.json 
  • This command has already filled in for you the Content-Type, Organization Id and URL with the first model id associated with your account

  • You will need to paste in your authentication key

user ~ % curl -H "Content-Type: application/json" \
-H "x-corsali-organization-id: Xxx...." \
-H "Authorization: Bearer eyJxxx.eyJxxx.1ANxxx" \
https://api.corsali.com/predict/Xxx....

Fill in your input data with the name of the file you created

user ~ % curl -H "Content-Type: application/json" \
-H "x-corsali-organization-id: Xxx...." \
-H "Authorization: Bearer eyJxxx.eyJxxx.1ANxxx" \
-d @example_json https://api.corsali.com/predict/Xxx....

Hit "enter" and send your first API Request!

: Carries credentials containing the authentication information for the model being queried

: Indicates the media type (text/html or text/JSON) of the request

: Specifies the organization to ensure you have permission to access the requested model

Now you are ready to go through the .

There are many different ways to interact with a REST API. The demo uses python code but we provide an example using as well as . Read through one or both of these examples to see how the inputs we defined above are passed into an API request. If you are feeling ambitious and want to run through a cURL request as well continue reading!

If you do not have an authentication key (or lost yours), . Remember to save it to a secure location as it can only be viewed once

Go to this and copy and paste the example command into your terminal. Note it refers to input data as example.json if you named your json something else you must change this.

API Walkthrough
cURL
python
follow this guide to generate one
page
Inputs to our REST API
Run Through API Example
Interacting with a REST API on Your Own
Full Request Steps: cURL
Authorization
Content-Type
x-corsali-organization-id