johanwinther / chalmers-card-balance
Public REST API for checking account balance of Chalmers Student Union cards
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 2
Open Issues: 1
Type:project
Requires
- php: >=5.5.0
- fabpot/goutte: ^3.2
This package is not auto-updated.
Last update: 2025-06-23 02:31:53 UTC
README
chalmers-card-balance
Public REST API for checking account balance of Chalmers Student Union cards
Installation
Add johanwinther/chalmers-card-balance
as a require dependency in your composer.json
file:
composer require johanwinther/chalmers-card-balance
Rename .htaccess.tmp to .htaccess and set the RewriteBase to the absolute folder path of card.php.
API
Show Card Balance
Returns JSON data of card balance.
-
URL
/<Card number>
-
Method:
GET
-
URL Params
Required:
Card number
- 16-digit Student Union card number -
Data Params
None
-
Success Response:
- Code: 200
Content:{ "cardHolder": "Emil Emilsson", "cardNumber": "1111222233334444", "cardBalance": { "value": 200.01, "currency": "kr" } }
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ "error": "Invalid card number: should be 16 digits." }
Explanation: Request was not 16 digits.
OR
- Code: 404 NOT FOUND
Content:{ "error": "Invalid card number: card not found." }
Explanation: Card is not registered in the system.
OR
- Code: 408 REQUEST TIMED OUT
Content:{ "error": "Connection timed out." }
Explanation: Could not load external service.
- Code: 400 BAD REQUEST
-
Sample Call:
$.ajax({ url: "https://ftek.se/api/v1/1111222233334444", dataType: "json", type : "GET", success : function(r) { console.log(r); } });