The API Manager is a script designed to facilitate API calls in a game or application. It provides a simple interface for making HTTP GET requests to a given URL and handling the JSON responses. It uses Unity's UnityWebRequest to handle web requests and offers callback delegates for success and failure scenarios. This allows developers to easily integrate API functionality into their projects while providing flexibility for handling various data types and error conditions.
Software - Unity, GitHub, APIs
Language - C#, Json
Team size - 1 Person
An API GET call is a request made by a client to fetch data from a server. The server processes the request and sends back the requested data in a response. It's commonly used to retrieve information without modifying anything on the server.
When using the GetCall function it takes in a few parameters: a APIRequest, a onComplete Action, and a onFailure Action.
APIRequest
The APIRequest is a class containing an URL which is where the call will be made to.
onComplete Action
The onComplete Action gets called when the web request is done and is successful. The Action contains a class that contains all the data that that API got from the server which got converted from a JSON response to a class.
onFailure Action
The onFailure Action gets called when the web request failed. The Action contains an APIStatus which holds the error message the web request gave back.
An API POST call is a request made to an API to add or create new data on the server. It sends data in the request body, and the server processes it to create a new resource.
An API PUT call is an HTTP request used to update existing data on a server. It's idempotent and requires sending the entire resource representation to the server.
An API DELETE call is an HTTP request that instructs the server to remove a specific resource. It's commonly used to delete data from databases or storage and is part of the CRUD operations in API interactions.