SDKs
Official Node.js and Python SDKs for the SignYu Aadhaar eSign API, plus the OpenAPI spec for generating your own client.
SignYu has official SDKs for Node.js and Python. They wrap every endpoint in this reference, send your API key for you, turn error responses into typed exceptions, and verify webhook signatures. Both are open source under the MIT license.
| Language | Package | Install |
|---|---|---|
| Node.js 18+ | signyu on npm | npm install signyu |
| Python 3.9+ | signyu on PyPI | pip install signyu |
Prefer another language? Generate a client from the OpenAPI 3.1 spec, or import the Postman collection from the button at the top of these docs.
Node.js
npm install signyu
import { readFileSync } from "node:fs";
import { SignYu } from "signyu";
const signyu = new SignYu({ apiKey: process.env.SIGNYU_API_KEY! });
const doc = await signyu.documents.create({
file: readFileSync("agreement.pdf"),
fileName: "agreement.pdf",
name: "Service Agreement",
});
await signyu.documents.addSigners(doc.documentId, [
{ name: "Asha Rao", phone: "9876543210", email: "asha@example.com" },
]);
const sent = await signyu.documents.send(doc.documentId);
console.log(sent.signers[0].signUrl);
The SDK has zero runtime dependencies and ships ESM and CommonJS builds with TypeScript types. file accepts a Buffer, Uint8Array, ArrayBuffer or Blob.
Methods
| Method | Endpoint |
|---|---|
documents.create({ file, fileName, name }) | POST /api/v1/documents |
documents.list({ limit, offset }) | GET /api/v1/documents |
documents.get(documentId) | GET /api/v1/documents/{documentId} |
documents.addSigners(documentId, signers) | POST /api/v1/documents/{documentId}/signers |
documents.send(documentId) | POST /api/v1/documents/{documentId}/send |
documents.getCertificate(documentId) | GET /api/v1/documents/{documentId}/certificate (returns PDF bytes) |
Errors
Any non 2xx response throws a SignYuError with status, code (the API's error field) and message. See Errors for every code.
import { SignYuError } from "signyu";
try {
await signyu.documents.send(documentId);
} catch (err) {
if (err instanceof SignYuError && err.code === "insufficient_credits") {
// top up credits, then retry
}
}
Webhooks
app.post("/webhooks/signyu", express.raw({ type: "application/json" }), (req, res) => {
const event = signyu.webhooks.constructEvent(
req.body,
req.header("X-SignSetu-Signature"),
process.env.SIGNYU_WEBHOOK_SECRET!
); // throws WebhookSignatureError if the signature is invalid
res.sendStatus(200);
});
Python
pip install signyu
from signyu import SignYu
client = SignYu(api_key="sk_live_your_api_key")
doc = client.documents.create(file="agreement.pdf", name="Service Agreement")
client.documents.add_signers(doc["documentId"], [
{"name": "Asha Rao", "phone": "9876543210", "email": "asha@example.com"},
])
sent = client.documents.send(doc["documentId"])
print(sent["signers"][0]["signUrl"])
Responses are plain dictionaries with the same camelCase keys as the JSON API, typed with TypedDict. file accepts a path, bytes, or a binary file object.
Methods
| Method | Endpoint |
|---|---|
documents.create(file, name=None, file_name=None) | POST /api/v1/documents |
documents.list(limit=None, offset=None) | GET /api/v1/documents |
documents.get(document_id) | GET /api/v1/documents/{documentId} |
documents.add_signers(document_id, signers) | POST /api/v1/documents/{documentId}/signers |
documents.send(document_id) | POST /api/v1/documents/{documentId}/send |
documents.get_certificate(document_id) | GET /api/v1/documents/{documentId}/certificate (returns PDF bytes) |
Errors
from signyu import SignYuError
try:
client.documents.send(document_id)
except SignYuError as err:
print(err.status, err.code, err.message)
Webhooks
import signyu
event = signyu.webhooks.construct_event(
request.get_data(), # raw body bytes
request.headers.get("X-SignSetu-Signature"),
os.environ["SIGNYU_WEBHOOK_SECRET"],
) # raises signyu.WebhookSignatureError if the signature is invalid
OpenAPI spec
The full API, including request and response schemas, error responses and webhook payloads, is described in /openapi.yaml (OpenAPI 3.1). Use it to generate clients in other languages or to import the API into tools like Postman, Insomnia or Swagger UI.