logo

Send API requests

Now that your API is ready, you can start to make requests! Anything that connects to the internet can make HTTP requests to your API: read, create, update and delete rows.

Endpoint format

The API endpoint is composed of three parts.

  • A uniquely generated id
  • The sheet name within your spreadsheet
  • Optionnaly a row id for Update and Delete endpoints
That's all. The endpoint is available in your dashboard in the code snippets section.

Fetch rows

To fetch all the rows from your sheet you make a GET request to your endpoint. For instance with a spreadsheet id 0grx5D9o and sheet name users:

fetch('https://app.apisheet.io/v1/0grx5D9o/users', { method: "GET"});

Create row

To create a row you make a POST request to your API endpoint with a JSON payload of your row. Your payload keys should be the name of your column. For instance, with a spreadsheet id 0grx5D9o and sheet name users and columns Name, Email, Is Director:

var payload = {
    "name": "Leon",
    "email": "leon@monster.inc",
    "isDirector": false,
};

fetch(
  'https://app.apisheet.io/v1/0grx5D9o/users',
  {
    method: "POST",
    body: JSON.stringify(payload),
    headers: { 'Content-Type': 'application/json' },
  }
);

Update row

To update a row you make a PUT request to your API endpoint plus the row id and a JSON payload. For instance with a spreasheet id 0grx5D9o, sheet name users and row id 2 and columns Name, Email, Is Director:

var payload = { "isDirector": true };

fetch(
  'https://app.apisheet.io/v1/0grx5D9o/users/2',
  {
    method: "PUT",
    body: JSON.stringify(payload),
    headers: { 'Content-Type': 'application/json' },
  }
);

Will update the row with row_id=2 with the given property values.

Delete row

To delete a row you make a DELETE request to your API endpoint with the row id. If the row id contains data it will be removed. Only data cells that correspond to the columns will be removed. For instance, with a spreadsheet id 0grx5D9o, sheet name users and row id 2:

fetch('https://app.apisheet.io/v1/0grx5D9o/users/2', { method: "DELETE" });

Will delete the row with row_id=2.

Got a question ? send a message!


© 2023 apisheet.io

About