API
CredoID Open API
CredoID REST API Documentation
Introduction
This document outlines how to interact with the CredoID REST API. This API provides access to resources of the CredoID Access Control Software. All requests and responses are formatted in JSON (JavaScript Object Notation).
Base URL
The base URL for all the API endpoints is http://localhost:8090/api.
Authorization
All API requests must be authorized with a JWT token. You can obtain this key from a login endpoint. Once you have your API key, you can provide it in the Authorization header of your requests like this:
Authorization: Bearer my_token
Swagger Documentation
For more information about the available API endpoints, please refer to our Swagger documentation at http://localhost:8090/swagger/index.html
API is split into these categories:
- Auth API: operator authentication-related endpoints
- Access Level API: This section manages and configures door access levels.
- Camera API: Here, you'll find operations for configuring camera devices and managing related settings.
- Dashboard API: operations for fetching various system statistics for dashboard displays.
- Device API: operations related to device configuration and discovery.
- Door API: category is used for configuring door settings and parameters.
- Elevator API: operations related to elevator configuration.
- Event API: event retrieval operations
- Filtering API: system filter management (used for event, trigger, report filtering)
- Location API: This covers operations related to managing system locations.
- Map API: Here, you'll find operations for managing and configuring maps within the system.
- Miscellaneous API: This part of the API covers various system-related operations that don't fall under other categories.
- Report API: This section of the API contains operations related to generating and managing system reports.
- Scripting API: Here, you'll find operations related to managing scripts.
- Settings API: This covers operations related to managing general system settings.
- Trigger Module API: This part of the API is for managing and configuring system triggers.
- User API: This section of the API is used for operations related to managing users, user access levels, and user credentials.
Making a Request
Here is an example of how to make a request to the CredoID API in C#. In this example, we use the HttpClient class in the System.Net.Http namespace to make HTTP requests. The /api/login endpoint is used to authenticate a user and obtain a JWT bearer token. This token is required for most other API calls.
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class Program
{
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
var loginResponse = await Login("admin", "admin");
Console.WriteLine(loginResponse);
}
static async Task<string> Login(string username, string password)
{
var requestBody = new
{
username = username,
password = password
};
var content = new StringContent(JsonConvert.SerializeObject(requestBody), Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://demo.credoid.com/api/login", content);
response.EnsureSuccessStatusCode();
var responseContent = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<dynamic>(responseContent).token;
}
}
NOTE: in example public demo CredoID address is used, when testing you should replace it with your own.
Response
If the login attempt is successful, the server will respond with a 200 OK status code and a JSON body containing the bearer token:
{
"token": "<bearer_token>"
}
This token should be used in the Authorization header for subsequent API calls.
Example of retrieving user list via GET /api/users endpoint
Description
The /api/users endpoint is used to retrieve a list of all users.
Request
Example URL
https://localhost:8090/api/users
Headers
Include the following header in your request:
Authorization: Bearer <your_bearer_token>
Response
Successful requests will return a 200 OK status code along with a JSON array containing user objects. Example output:
[
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"companyName": "ACME Corp.",
"departmentName": "Sales",
"userTitleName": "Sales Manager",
"employeeNumber": "JD123",
"email": "johndoe@example.com",
"phoneNumber": "+1234567890",
"version": "1.0",
"companyId": 101,
"departmentId": 201,
"titleId": 301,
"activationDate": "2023-06-01T00:00:00",
"expirationDate": "2023-12-31T23:59:59",
"hasImage": true
},
{
"id": 2,
"firstName": "Jane",
"lastName": "Smith",
"companyName": "ACME Corp.",
"departmentName": "Marketing",
"userTitleName": "Marketing Executive",
"employeeNumber": "JS456",
"email": "janesmith@example.com",
"phoneNumber": "+0987654321",
"version": "1.0",
"companyId": 101,
"departmentId": 202,
"titleId": 302,
"activationDate": "2023-06-01T00:00:00",
"expirationDate": null,
"hasImage": false
}
]
Contact Information
For any questions or issues regarding the API, please get in touch with our support team at https://credoid.atlassian.net/servicedesk/customer/portal/2.