API Documentation
This page is meant for developers, vendors, and IT administrators to understand how to generate the bearer token to access our API to get/create/update shortlinks.
Last updated
This page is meant for developers, vendors, and IT administrators to understand how to generate the bearer token to access our API to get/create/update shortlinks.
Last updated
Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. GoGovSG uses bearer authentication.
To generate the token, click on "API Integration" in the navigation bar. From there, click on Generate API key
and copy the token. Use this key to start using GoGovSG's API.
Keep the bearer token safe: You should not share the bearer token with anyone. Use services like 1Password to store it.
GoGovSG's API uses APIKey for authentication. User can view and manage API Keys in Go API Dashboard.
Staging secret keys will have test_v1_
version prefix.
Production secret keys will have live_v1_
version prefix.
Authentication to the API is performed via bearer auth.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail and requests without authentication will also fail.
Go API uses conventional API Error to indicate the success or failure of an API request.
GoGovSG supports a default rate limit of 5 requests per second for each user. If you require higher rate limits, please write to us at go@open.gov.sg with more details.
If you have exceeded your rate limit, your incoming requests will be blocked for 10 seconds as a cooling off period. We recommend throttling your requests and implementing exponential backoff for retries to ensure that your requests can be accepted.
Request Query Parameters:
Note: Max values for limit
= 1000
Returns:
Explanation of fields returned:
Request body:
longUrl
has to start with https://
If no shortUrl
is provided, then a random 8 character alphanumeric shortUrl name will be generated for the link.
Returns:
Note: Indicate shortUrl
name you wish to update in above PATCH request, ie. {shortUrl}
Request body:
longUrl
has to start with https://
Returns:
Status Codes | Description |
---|---|
Environment | Endpoint |
---|---|
Parameter | Type | Default value | Required? |
---|---|---|---|
Field Returned | What it means | Example |
---|---|---|
Property | Type | Required? |
---|---|---|
Property | Type | Required? |
---|---|---|
200 - OK
Everything worked as expected.
400 - Bad Request
The request was unacceptable, often due to missing a required parameter.
401 - Unauthorized
No valid API key provided.
402 - Request Failed
The parameters were valid but the request failed.
404 - Not Found
The requested resource doesn't exist.
429 - Too Many Requests
Too many requests hit the API too quickly. We recommend an exponential backoff of your requests.
500, 502, 503, 504 - Server Errors
Something went wrong on GoGovSG's API end.
Production
Staging
limit
number
1000
No, optional
offset
number
0
No, optional
searchText
string
nil
No, optional
state
enum (”ACTIVE”, “INACTIVE”)
nil
No, optional
orderBy
enum (”createdAt”, “clicks”)
createdAt
No, optional
sortDirection
enum (”desc”, “asc”)
desc
No, optional
isFile
boolean
nil
No, optional
shortUrl
Short link name
agsubmit (ie. full URL will look like https://go.gov.sg/agsubmit)
longUrl
Original link
https://google.com
state
Whether short link is active or inactive
"ACTIVE" or "INACTIVE"
clicks
Number of clicks on the short link since creation
888
count
Counts the total number of links matching search filters (except limit
and offset
)
8
longUrl
string
Yes, required
shortUrl
string
No, optional
longUrl
string
No, optional
state
enum (”ACTIVE”, “INACTIVE”)
No, optional