This document describes the REST API wrapper that provides HTTP access to PayStream smart contracts for teams that cannot use the JavaScript SDK directly.
The REST API is implemented as a separate Node.js/Express service that wraps all contract functions, enabling teams to interact with PayStream via standard HTTP requests instead of direct blockchain calls.
The REST API implementation is located in the parent directory:
../paystream-rest-api/
✅ Complete Contract Coverage
- All stream contract functions
- All token contract functions
- Admin and governance operations
✅ OpenAPI Specification
- Auto-generated documentation at
/api-docs - Interactive Swagger UI
- Complete request/response schemas
✅ API Key Authentication
- Secure access via
X-API-Keyheader - Configurable multiple API keys
- Proper error handling for auth failures
✅ Rate Limiting
- Configurable request limits
- IP-based protection
- Abuse prevention
- Navigate to REST API directory:
cd ../paystream-rest-api/- Install dependencies:
npm install- Configure environment:
cp .env.example .env
# Edit .env with your contract IDs and API keys- Start the server:
npm start- Access API documentation:
http://localhost:3000/api-docs
POST /api/streams/create- Create new streamPOST /api/streams/create-batch- Create multiple streamsPOST /api/streams/{id}/withdraw- Withdraw earningsPOST /api/streams/{id}/top-up- Add fundsPOST /api/streams/{id}/pause- Pause streamPOST /api/streams/{id}/resume- Resume streamPOST /api/streams/{id}/cancel- Cancel streamPOST /api/streams/{id}/update-rate- Update rateGET /api/streams/{id}- Get stream infoGET /api/streams/{id}/claimable- Get claimable amountGET /api/streams/by-employer/{address}- Get employer streamsGET /api/streams/by-employee/{address}- Get employee streamsGET /api/streams/count- Get total streams
GET /api/tokens/total-supply- Get total supplyGET /api/tokens/balance/{address}- Get balancePOST /api/tokens/transfer- Transfer tokensPOST /api/tokens/approve- Approve spendingPOST /api/tokens/mint- Mint tokensPOST /api/tokens/burn- Burn tokens
POST /api/admin/initialize- Initialize contractPOST /api/admin/pause-contract- Pause contractPOST /api/admin/set-min-deposit- Set minimum depositPOST /api/admin/upgrade- Upgrade contract
POST /api/governance/propose- Propose parameter changePOST /api/governance/vote- Vote on proposalGET /api/governance/proposal/{id}- Get proposal info
All endpoints require an API key:
curl -H "X-API-Key: your-api-key" \
http://localhost:3000/api/streams/countcurl -X POST \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"employer": "GD5...",
"employee": "GB7...",
"token_address": "CC7...",
"deposit": "1000000",
"rate_per_second": "100",
"stop_time": 0,
"cooldown_period": 0,
"cliff_time": 0
}' \
http://localhost:3000/api/streams/createcurl -H "X-API-Key: your-api-key" \
http://localhost:3000/api/streams/1cd ../paystream-rest-api/
docker build -t paystream-api .
docker run -p 3000:3000 --env-file .env paystream-apicd ../paystream-rest-api/
docker-compose up- API key authentication required for all endpoints
- Rate limiting prevents abuse
- Input validation on all requests
- HTTPS recommended for production
For REST API issues, see the main repository documentation or create issues in the REST API project.
The REST API maintains full compatibility with all existing contract functions and does not require any changes to the smart contracts themselves.