API - netnutmike/subracetracker GitHub Wiki
There are 2 parts to the API. The first part is retrieving data from the database in a JSON format. That is done by calling data/getjson.php with some parameters.
The second part requires authorization and will actually make changes in the form of updates, deletes, inserts, etc.
Below we will describe each of the 2 methods. Both methods use POST so the data can be protected by using SSL.
NOTE
This API is written to be on a private network with no internet access. There is very very basic authentication and no authorization built into this API. There is also no SQL injection protection, role based access, cross site scripting protection, no man in the middle protections, no session tracking, no IP tracking, etc. It is the most basic of APIs. These features can be added later if they are needed.
As mentioned above, there is no authentication for pulling data. The data is delivered in a JSON format. You access the data by calling /data/getjson.php and providing the dataset you are want to pull by adding ?dataset=. Most datasets have additional parameters that can be provided to pull specific data or sort the data differently than the default.
Below is the list of current datasets with links to more information about each dataset.
There are currently 5 actions that can be performed on data in the database. They are:
- New (Insert)
- Update
- Delete
- Enable
- Disable
Like the getjson routine, you provide a dataset name and an action. You post both dataset and action with the rest of the data that is needed to perform the action. For example, if you wanted to delete a team record, you would send the uid of the team you want to delete, the dataset of teams, an action of delete and the current authentication string in a POST to /data/actions.php.
Below we will have each dataset that can be manipulated via the actions, that link will take you to more information about what actions are available for that dataset and the additional information that is needed in the post to perform the action.