Files
dolibarr/htdocs/api
Jon Bendtsen 783807af14 Tiniest event attendee API - just the POST endpoint (#33934)
* check if MAIN_AGENDA_XCAL_EXPORTKEY is set before using it

* suggestion from frederic34

* adding 5 new statuses and their functions

* adding 5 new statuses and their functions

* copy and modified from email template api

* remove some unset because they are present in the database

* all objects are ConferenceOrBoothAttendee's

* load eventattendee API file from eventorganization/ folder

* ref is not required and should perhaps be banned because it is ignored during create + nonexisting apifetch function replaced with call to just fetch + making usre to use the correct class

* variable named paid is unused?

* get all event attendees

* fixing the sql statement

* adjusting function checking access rights

* UNTESTED! multicompany support by leftjoining with the projet table which does have an entity column + adjusting checkAccessRights function to prepare for testing project visibility

* adding more statuses and explaining boarding pass better

* expanding access rights checks with a project id and starting to use that after fetch so we know the project_id

* checking if the user has access to the project specified in fk_project

* phan fix getting  right

* checking if isModEnabled('multicompany')

* will only show rows of projects which is either public or the user is a contact of

* 2 new status changing functions and some protection for the existing status changing functions

* fix pre-commit check

* typo fix = that should be ==

* adding extrafields and linkedobjectids to event attendee

* should be back to develop branch contents so PR can be smaller

* reducing PR size, just GET and POST

* smallest commit, just the post and functions needed by post

---------

Co-authored-by: Jon Bendtsen <xcodeauthor@jonb.dk>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-04-22 11:45:50 +02:00
..
2024-11-10 23:47:14 +01:00
2022-03-02 00:29:07 +01:00

API REST

Integrate your ERP with any other applications using Dolibarr APIs

This module provides the service to make Dolibarr a server of REST Web Services. It depends on external library Restler.

Extract any data or push insert, update or delete record using our new REST APIs. Using standard HTTP and Json format, it is compatible with any language (PHP, Java, Ruby, Python, C#, C++, JavaScript, JQuery, Basic, ...). Use the embedded APIs explorer tool to test APIs or get generated URLs to use in your own code.

Dolibarr API explorer

Explore the APIs

You can explore all available APIs by using the API explorer : yourdolibarr.tld/api/index.php/explorer (replace yourdolibarr.tld by real hostname of your Dolibarr installation)

Access to an API

Warning : access to any API should (or better : must!) be secured with SSL connection

To access to the API you need a token to identify. Only this token will allow to access API with. The token is dedicated to a user and it must be put into requests as DOLAPIKEY parameter in HTTP header (or among URL parameters, but this is less secured).

To get a token you can:

  • Edit the user card to set the value of token. Each user can have a different token.
  • or Call the login API with login and password. This will return the value of token for the user used to login.

Then call other services with

https://yourdolibarr.tld/mydolibarr/api/index.php/otherservice?DOLAPIKEY=api_key

Develop an API

The API uses Lucarast Restler framework. Please check documentation https://www.luracast.com/products/restler and examples https://restler3.luracast.com/examples/index.html

Github contains also useful information : https://github.com/Luracast/Restler

To implement it into Dolibarr, you need to create a specific class for object we want to use. A skeleton file is available into /modulebuilder/class directory : api_mymodule_class.class.php The API class file must be put into object class directory, with specific file name. By example, API class file for 'myobject' must be put as : /htdocs/myobject/class/api_myobject.class.php. Class must be named MyobjectApi.

If a module provide several object, use a different name for 'myobject' and put the file into the same directory.

Define url for methods

It is possible to specify url for API methods by simply use the PHPDoc tag @url. See examples :

/**
* List contacts
* 
* Get a list of contacts
*
* @url	GET /contact/list
* @url	GET /contact/list/{socid}
* @url	GET	/thirdparty/{socid}/contacts
* [...]

Other Annotations Other annotations are used, you are encouraged to read them : https://github.com/Luracast/Restler/blob/master/ANNOTATIONS.md

PHPDoc tags can also be used to specify variables information for API. Again, rtfm : https://github.com/Luracast/Restler/blob/master/PARAM.md