PDFfiller API You can sign up for the API here.
- Node.js >= v4 but the latest stable version of NodeJS is recommended;
npm i pdffiller-nodejs-api-client --save
You can require PDFfiller module as a singleton and use it in anywhere your app, or require constructor and create different instances:
const PDFfiller = require('pdffiller-nodejs-api-client').PDFfiller;
// or
const PDFfillerConstructor = require('pdffiller-nodejs-api-client').PDFfillerConstructor;
Or using ES6:
import { PDFfiller, PDFFillerConstructor } from 'pdffiller-nodejs-api-client';
Access tokens will automatically initialize when you’re successfully retrieved from the given user's credentials.
The second parameter auto_update
when you set up it as true
token will automatically update when expire
PDFfiller.auth.authorize({
grant_type: 'password',
client_id: 'your_client_id',
client_secret: 'your_client_secret',
username: 'username@mail.com',
password: 'your_password'
}, true)
.then(accessTokenData => console.log(accessTokenData))
.catch(err => console.error(err));
When your authorization has been completed successfully you can use client for retrieving, creating, updating or deleting information from your profile.
Also you can set up token, for future request:
PDFfiller.auth.setAccessToken('your_access_token');
and get current access token:
PDFfiller.auth.getAccessToken();
Use a method to retrieve a list of all applications:
PDFfiller.applications.all()
.then(applications => console.log(applications))
.catch(err => console.error(err));
Use a method to retrieve an applications by id:
PDFfiller.applications.get(application_id)
.then(application => console.log(application))
.catch(err => console.error(err));
Use a method to create an application:
PDFfiller.applications.create({
name: 'app name',
description: 'app description',
domain: 'http://domain.com'
})
.then(application => console.log(application))
.catch(err => console.error(err));
Use a method to update an application by id:
PDFfiller.applications.update(application_id, {
name: 'app name',
description: 'app description',
domain: 'http://domain.com'
})
.then(application => console.log(application))
.catch(err => console.error(err));
Use a method to delete an application by id:
PDFfiller.applications.remove(application_id)
.then(result => console.log(result))
.catch(err => console.error(err));
Use a method to get application users:
PDFfiller.applications.users(application_id)
.then(users => console.log(users))
.catch(err => console.error(err));
All examples with other endpoints are available in the docs folder.
We send request using request-promise library, so to send a file you can just pass a file stream, for example:
const fs = require('fs');
PDFfiller.templates.create({
file: fs.createReadStream('./file.pdf'),
name: 'test_file_load.pdf'
})
.then(createdTemplateInfo => console.log(createdTemplateInfo))
.catch(err => console.error(err));
When you download files we will return Buffer object after you can save it as in example:
const fs = require('fs');
PDFfiller.templates.download(template_id)
.then(templateFileBuffer => {
fs.writeFile('./your_file_name.pdf', templateFileBuffer, (err) => {
if (err) {
console.log(err);
return;
}
console.log('successfully saved');
});
})
.catch(err => console.error(err));
Methods provide not only Promise api, you can use callbacks if you want. You can pass callback function to all methods as last argument, in this case methods dont return a Promise:
const fs = require('fs');
PDFfiller.templates.create({
file: fs.createReadStream('./file.pdf'),
name: 'test_file_load.pdf'
}, (err, response, body) => {
if (err) {
console.log(err);
}
// YOUR CODE
}
);
PDFfiller.auth.authorize({
grant_type: 'password',
client_id: 'your_client_id',
client_secret: 'your_client_secret',
username: 'username@mail.com',
password: 'your_password'
}, false, (err, body) => {
if (err) {
console.log(err);
}
// YOUR CODE
}
);
If you have any problems feel free to contact us:
- On our issues page https://github.com/pdffiller/pdffiller-nodejs-api-client/issues
- Via chat or phone at our tech site https://developers.pdffiller.com
This software is licensed under the following MIT license
See CONTRIBUTING.
API Team (integrations@pdffiller.com)