Python SDK for the AccessGrid API
Project description
AccessGrid SDK
A JavaScript SDK for interacting with the AccessGrid.com API. This SDK provides a simple interface for managing NFC key cards and enterprise templates. Full docs at https://www.accessgrid.com/docs
Installation
npm install accessgrid
Quick Start
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
API Reference
Access Cards
Provision a new card
const card = await client.accessCards.provision({
cardTemplateId: "0xd3adb00b5",
employeeId: "123456789",
tagId: "DDEADB33FB00B5",
allowOnMultipleDevices: true,
fullName: "Employee name",
email: "employee@yourwebsite.com",
phoneNumber: "+19547212241",
classification: "full_time",
startDate: "2025-01-31T22:46:25.601Z",
expirationDate: "2025-04-30T22:46:25.601Z",
employeePhoto: "[image_in_base64_encoded_format]"
});
Update a card
const card = await client.accessCards.update({
cardId: "0xc4rd1d",
employeeId: "987654321",
fullName: "Updated Employee Name",
classification: "contractor",
expirationDate: "2025-02-22T21:04:03.664Z",
employeePhoto: "[image_in_base64_encoded_format]"
});
Manage card states
// Suspend a card
await client.accessCards.suspend({
cardId: "0xc4rd1d"
});
// Resume a card
await client.accessCards.resume({
cardId: "0xc4rd1d"
});
// Unlink a card
await client.accessCards.unlink({
cardId: "0xc4rd1d"
});
Enterprise Console
Create a template
const template = await client.console.createTemplate({
name: "Employee NFC key",
platform: "apple",
useCase: "employee_badge",
protocol: "desfire",
allowOnMultipleDevices: true,
watchCount: 2,
iphoneCount: 3,
design: {
backgroundColor: "#FFFFFF",
labelColor: "#000000",
labelSecondaryColor: "#333333",
backgroundImage: "[image_in_base64_encoded_format]",
logoImage: "[image_in_base64_encoded_format]",
iconImage: "[image_in_base64_encoded_format]"
},
supportInfo: {
supportUrl: "https://help.yourcompany.com",
supportPhoneNumber: "+1-555-123-4567",
supportEmail: "support@yourcompany.com",
privacyPolicyUrl: "https://yourcompany.com/privacy",
termsAndConditionsUrl: "https://yourcompany.com/terms"
}
});
Update a template
const template = await client.console.updateTemplate({
cardTemplateId: "0xd3adb00b5",
name: "Updated Employee NFC key",
allowOnMultipleDevices: true,
watchCount: 2,
iphoneCount: 3,
supportInfo: {
supportUrl: "https://help.yourcompany.com",
supportPhoneNumber: "+1-555-123-4567",
supportEmail: "support@yourcompany.com",
privacyPolicyUrl: "https://yourcompany.com/privacy",
termsAndConditionsUrl: "https://yourcompany.com/terms"
}
});
Read a template
const template = await client.console.readTemplate({
cardTemplateId: "0xd3adb00b5"
});
Get event logs
const events = await client.console.eventLog({
cardTemplateId: "0xd3adb00b5",
filters: {
device: "mobile", // "mobile" or "watch"
startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString(),
endDate: new Date().toISOString(),
eventType: "install"
}
});
Configuration
The SDK can be configured with custom options:
const client = new AccessGrid(accountId, secretKey, {
baseUrl: 'https://api.staging.accessgrid.com' // Use a different API endpoint
});
Error Handling
The SDK throws errors for various scenarios including:
- Missing required credentials
- API request failures
- Invalid parameters
- Server errors
Example error handling:
try {
const card = await client.accessCards.provision({
// ... parameters
});
} catch (error) {
console.error('Failed to provision card:', error.message);
}
Requirements
- Node.js 12 or higher
- Modern browser environment with support for:
- Fetch API
- Web Crypto API
- Promises
- async/await
Security
The SDK automatically handles:
- Request signing using HMAC-SHA256
- Secure payload encoding
- Authentication headers
- HTTPS communication
Never expose your secretKey in client-side code. Always use environment variables or a secure configuration management system.
License
MIT License - See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file accessgrid-0.1.0.tar.gz.
File metadata
- Download URL: accessgrid-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60837f780a395daaaf808500d7c468e056c4f9afc3c06f34008b0dbd843d366e
|
|
| MD5 |
4fb3e68005a853c7a1ea97ecc3909092
|
|
| BLAKE2b-256 |
c42f5b4658c89c1dc22a9c492fb42fd4e6a775e37480b8d552335215b7c60620
|
File details
Details for the file accessgrid-0.1.0-py3-none-any.whl.
File metadata
- Download URL: accessgrid-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4189f7bf750ac6e393380242b1c202cd804717dd3454347123ff8bd15f47705
|
|
| MD5 |
c33cd3c41a4b1ddbf8a39645c984d218
|
|
| BLAKE2b-256 |
90cc51ee67950c3eaed6aa31d4bb94c33dd605fcb9c646ad5361da5760340fa1
|