Permalink
Fetching contributors…
Cannot retrieve contributors at this time
108 lines (87 sloc) 4.09 KB

Other

Edit on GitHub

Multiple sheets

# Get whole spreadsheet from sheet named Sheet2
curl "https://sheetsu.com/apis/v1.0/020b2c0f/sheets/Sheet2"
# Adds single row to sheet named "Sheet2"
curl "https://sheetsu.com/apis/v1.0/020b2c0f/sheets/Sheet2" \
-X POST \
-H "Content-Type: application/json" \
-d '{ "foo": "6", "another column": "quux" }'
require 'sheetsu'
sheetsu = Sheetsu::Client.new("020b2c0f")
# Get whole spreadsheet from sheet named Sheet2
sheetsu.read(sheet: "Sheet2")
# Adds single row to sheet named "Sheet2"
sheetsu.create({ "foo" => "bar", "another column" => "quux" }, "Sheet2")

By default, always the first sheet (aka worksheet aka tab) is accessed. To access other sheets within a spreadsheet add /sheets/{sheet_name} path to the URL if using cURL, or pass appropriate param when using a lib.

Authentication

curl "https://sheetsu.com/apis/v1.0/020b2c0f" \
-u 'your_api_key:your_api_secret'
# Create new client object with HTTP Basic Auth keys
sheetsu = Sheetsu::Client.new(
  "020b2c0f",
  api_key: "YOUR_API_KEY",
  api_secret: "YOUR_API_SECRET"
)

You can secure your API with HTTP Basic authentication. It can be turned on in the API settings.

You have to send api_key and api_secret when you have authentication turned on.

Creating API programmatically

# Creates new API
curl "https://sheetsu.com/apis/v1.0/api_sheets" \
-X POST \
-H "Content-Type: application/json" \
-d '{ "email": "your@email.com", "api_key": "api_key", "google_spreadsheet_url": "your_doc_url" }'

API can be created by sending POST request to https://sheetsu.com/apis/v1.0/api_sheets. This feature is not available in all plans - check pricing page to know more. Please contact support to get your api_key.

Assigning permissions to an API

While creating new API, you can assign read/write permission as well as set up authentication for the API. By default, all permissions are set to true.

# Creates new API with HTTP Basic Auth
curl "https://sheetsu.com/apis/v1.0/api_sheets" \
-X POST \
-H "Content-Type: application/json" \
-d '{ "email": "your@email.com", "api_key": "api_key", "google_spreadsheet_url": "your_doc_url", authenticate: true }'
# Creates new API with only write permission enabled
curl "https://sheetsu.com/apis/v1.0/api_sheets" \
-X POST \
-H "Content-Type: application/json" \
-d '{ "email": "your@email.com", "api_key": "api_key", "google_spreadsheet_url": "your_doc_url", can_create: true, can_read: false, can_update: false, can_delete: false }'

Rate Limits

Every API has a rate limit. You can check rate limitś for APIs on the pricing page. After hitting the limit for the particular API, you receive 429 Rate limit exceeded status code.

HTTP Status Codes

Every response from the API is a JSON encoded string with a significant HTTP status code.

Code Description
200 OK Standard response for successful GET, PUT and PATCH requests
201 Created Successful response for POST requests
204 No Content Successful response for DELETE requests
400 Bad Request Error response when creating (POST) or updating (PUT, PATCH) row(s)
401 Unauthorized Error response when wrong authorization credentials provided
402 Payment Required Returned if pro feature (multiple sheets) is tried to be accessed from free account
403 Forbidden Error response when action is forbidden by the user (API owner)
404 No such route Error response when route doesn't exist
429 Rate limit exceeded Error response when API hits quota exceeded
500 Server error

Each API URL has an id, which identifies it. It is part of the URL which is after https://sheetsu.com/apis/v1.0/.