0% found this document useful (0 votes)
24 views

Operia - How To Build An API Call

The document provides instructions for building API calls to the Operia API. It describes three main steps: 1) specifying the target URL, 2) encoding the URL, and 3) constructing the full API call URL by combining the API key, encoded URL, and base URL. It also provides examples of calling the statistics endpoint to retrieve daily or monthly statistics over a specified number of days or months. Errors are returned as HTTP status codes in the 4xx or 5xx range with a description in the response body. The document concludes by noting that the API key should be protected since it is included in URLs and could be exposed, and that a more secure authentication method is available upon request.

Uploaded by

duong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Operia - How To Build An API Call

The document provides instructions for building API calls to the Operia API. It describes three main steps: 1) specifying the target URL, 2) encoding the URL, and 3) constructing the full API call URL by combining the API key, encoded URL, and base URL. It also provides examples of calling the statistics endpoint to retrieve daily or monthly statistics over a specified number of days or months. Errors are returned as HTTP status codes in the 4xx or 5xx range with a description in the response body. The document concludes by noting that the API key should be protected since it is included in URLs and could be exposed, and that a more secure authentication method is available upon request.

Uploaded by

duong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

How to build an API Call

Building your API call is easy

The first step – know your target URL:

There are many web targets that are supported using this API.
Find the URL that you’re interested in and add any needed parameters
https://www.example.com?paramter=value&paramter2=value2

Second step – Encode your target URL:

Using URL-encode, please encode your selected target URL.


https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.example.com%3Fparamter%3Dvalue%26para
mter2%3Dvalue2

Third step – API call format:

The first part of the API call is as follows:


https://run.operia.io/API_KEY/?url=

The second part is the encoded URL:


https://run.operia.io/API_KEY/?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.ex
ample.com%3Fparamter%3Dvalue%26paramter2%3Dvalue2
Statistics API
In order to know the statistics, you can use the following:

To show daily statistics for the last 30 days, use one of the following similar
urls:

https://run.operia.io/__KEY__/statistics
https://run.operia.io/__KEY__/statistics/daily
https://run.operia.io/__KEY__/statistics/daily/30

To specify another amount of days, either change it in the last url, or add
the ?days=XX parameter to any of the urls:

https://run.operia.io/__KEY__/statistics/daily/60
https://run.operia.io/__KEY__/statistics?days=60

To show monthly statistics for the last 12 months, use one of the following
similar urls:

https://run.operia.io/__KEY__/statistics/monthly
https://run.operia.io/__KEY__/statistics/monthly/12

To specify another amount of months, either change it in the last url, or


add the ?months=XX parameter to any of the urls:

https://run.operia.io/__KEY__/statistics/monthly/24
https://run.operia.io/__KEY__/statistics/monthly?months=24
Errors
On failure, the response status code will be in the range of 4xx-5xx and
the error string will be returned as the response body.

Failed sending request to the backend provider


or parsing provider’s response. Feel free to
REQUEST_FAILED resend the request, it may be served by a
different provider next time. You will not be
charged for the failed request.
Provider did not respond in a timely manner.
Feel free to resend the request, it may be
REQUEST_TIMED_OUT
served by a different provider next time. You will
not be charged for the timed-out request.
Your account does not have enough credits to
NO_CREDITS process the request. Please contact us for
options.
The supplied URL is invalid. Make sure it includes
INVALID_URL the scheme ( http:// or https:// ) and that it
is properly encoded.

No credits 402
Request Timeout: 500
Request Failed: 500
Invalid URL: 400
How to protect your API key
Since (most) requests to the API are performed using the HTTP GET method
to a URL which includes your KEY, it’s relatively easy to expose it to
unwanted parties. You should be aware of this when sharing constructed
API links with peers.

Another point to consider is that most messaging platforms today attempt


to generate preview of shared links, which would trigger a valid API call
and charge credits from your account. For this reason it is recommended
to avoid sending constructed API links which includes your KEY via these
platforms.

If you believe your key has been compromised, please contact us right
away and we will send you a new key.

A more secure authentication method also exists. If you’re interested in


using it, please contact us.

You might also like