Many of our customers have a strong background in using SQL to retrieve data. This article will answer some common questions on how to use APIs, in terms more familiar to this user.
Q: How do I retrieve all the records?
Whenever using an endpoint like "Get all Students" or "Get all Classes", is not possible to make one call and fetch all of the records. Whereas with databases, you can select all of the records at once. However, since APIs use network requests rather than local socket connection, APIs that have many records are broken up into many pages.
This following article explains this in more detail:
Q: Sometimes it does not respond, and gives error. What do I do?
As discussed above, since APIs are network requests and thus public to the whole internet, instead of installed locally, we need to take precautions against heavy usage. This is why APIs are necessarily throttled with a rate limit. In this way, we can ensure high degree of availability for customers.
This article explains this in more detail:
Q: How are the records structured?
APIs do not give responses back in rows and columns, instead they respond in JSON, which is a nested data type. Instead of columns there are keys, but these keys are nested inside of each other.
For example, the keys for "Get all Students" endpoint are two: "students" and "meta". The "students" key contains multiple objects, which have properties. The "meta" key contains information about the response itself.
In order to retrieve the different columns, instead of using a "select" statement, you have to parse the responses by extracting the nested information.
Q: How can I do a CONCAT or other function?
APIs are not able to execute functions such as CONCAT or CASE … WHEN. Instead, you can use the programming language that is being used to consume the APIs. For example, instead of sending a CONCAT function via an API, use the API as normal, and then in JavaScript you can use `string1.concat(string2)` method. If you are using Python, you can use `f'{string1} {string2}'`