Onprint uses OAuth2 as authentication standard. First, a token must be retrieved from a token endpoint, and then any call to the API, except the EnrichedImage and Click endpoints, must specify OAuth2 authentication type and token in the header. We will explain it more in detail below.
The first step at login is to get a token using the standard OAuth2 request, also with a header containing the ApiKey. Username and password must be provided as a formData content. Example of form-data:
grant_type=password&username=toto@onprint.com&password=test
The content-type of the POST request must be application/x-www-form-urlencoded
The ApiKey Header must be provided as follows. It will return a Json containing user information and the token :
ApiKey:xxx
The token is in the field: access_token
The token has an expiration date, also available in the response.
Once we have the token to connect, we will use OAuth authentication for every API call, except the ones described below. The header must be built as follows:
Value: bearer token value
Example: Authorization: Bearer AQAAANCMnd8BFdERjHoAwE_Cl-sBAAAAHufd(…)
These endpoints are for image search or user creation / password recovery. As they do not require authentication, the ApiKey header (as well as others, see details in each endpoint part) will have to be set.
Objects in the platform are organized in nodes. Here are the main rules:
3 roles can be used in the Onprint API. A user can have one or more roles.
Here is a list of the main Return Codes in use in the application.
Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource.
Example of use: in resource Folder, in GET /api/Folders/{id}, if the folder is found it is returned in the response body with return code 200.
The request has been fulfilled, resulting in the creation of a new resource.
Example of use: in resource Document, in POST /api/Documents, if the document could be created with no errors, return code is 201. The new document is returned in the response body.
The server successfully processed the request and is not returning any content.
Example of use: in resource EnrichedImage, in POST /api/EnrichedImages, if the request was successful but no corresponding image was recognized, or did not contain any action, the return code is 204.
Another example: in resource DocumentLanguage, in PUT /api/DocumentLanguages, if the language was correctly added to the document, the return code is 204.
The server cannot or will not process the request due to an apparent client error. Example of use: in resource Icon, in PUT /api/Icons/{id}, if the image that is sent in the request is too large, the server will not be able to process the request and will respond 400.
When authentication is required and has failed or has not yet been provided.
Example of use: in any resource that needs authentication, if the Authorization header is not set, the server will respond 401.
The request was a valid request, but the server is refusing to respond to it.
Example of use: in resource Account, in GET /api/accounts?organizationId={id}, if the user role does not allow him/her to see the organization, the response will be 403.
The requested resource could not be found but may be available in the future. Example of use: in resource Action, in POST /api/Actions, If the given parent DocumentId does not lead to an existing document, the server will say that the resource cannot be found and return 404.
This error should not happen, but can be raised when we did not handle properly something on the server side. Sometimes because of a bad request, or a bug. If you encounter this, please contact Onprint.
Document management.
| Property | Type | Description | Comment |
|---|---|---|---|
| Id | Guid | Read-Only, generated | |
| ParentId | Guid | ||
| DefaultLanguage | String | Default language used for scan | |
| Name | String | ||
| ContentType | String | MIME ContentType | Read-Only |
| Pages | Int | Pages count | Read-Only |
| ActionCount | Int | Action Count | Read-Only |
| Status | String | (see below) Can only be from active to inactive and back | |
| Cover | String | Document Cover thumbnail URL | Read-Only |
| DateCreated | DateTime | Read-Only | |
| DateModified | DateTime | Read-Only |
Document Status enumeration
The POST method is used to create a document by sending the document file and its properties.
The request body content type must be Multipart (multipart/form-data). The content is made of a File data (file) and a Form data (document).
In the URL, a parameter named async can be set like this: POST /api/Documents?async=false. Defaults to true if not set. When this parameter is true, the image creation is made asynchronously and the method returns directly. When it is false, the method waits for the image creation before returning. The difference between both methods is important in the case of a PDF file.
The document itself. It can be a JPEG, PNG, GIF image, or a PDF document. The MIME type has to be given in the file content type.
Contains a Document object. The form data name is document. DefaultLanguage, Name and ParentId are mandatory.
PUT is a multipart method where only the attached file will be read, to replace the image. To modify document properties, a PATCH will have to be done.
The document replacement itself. It can be a JPEG, PNG, GIF image, or a PDF document. The MIME type has to be given in the file content type.
Can be sent independently: DefaultLanguage, Name, ParentId, Status.
Images are contained into a document. They are created when creating the document; it is not possible to create an image outside a document.
| Property | Type | Description | Comment |
|---|---|---|---|
| Id | Guid | Read-Only, generated | |
| DocumentId | Guid | ||
| Status | String | (see below) | Read-Only |
| Name | String | ||
| ActionCount | Int | Read-Only | |
| ZoneCount | Int | Read-Only | |
| Order | Int | Order in document | |
| AutoTrigger | Bool? | Auto trigger of the action. Only if 1 action | |
| SmallThumbnail | String | 100px thumbnail | Read-Only |
| BigThumbnail | String | 700px thumbnail | Read-Only |
| DateCreated | DateTime | Read-Only | |
| DateModified | DateTime | Read-Only |
Image status enumeration
Name, Order, Status are mandatory.
Can be sent independently: AutoTrigger, Name, Order, Status.
Action management.
| Property | Type | Description | Comment |
|---|---|---|---|
| Id | Guid | Read-Only, generated | |
| NodeId | Guid | ||
| IconId | Guid | Optional | |
| IsValid | Bool | An action is valid when all fields respect rules | |
| LanguageCode | String | ||
| Priority | Int? | Allows to sort actions | |
| Order | Int? | Allows to sort actions | |
| Name | String | ||
| Style | String | Style, given as a css-like string | |
| Type | String | (see below) | |
| Content | String | Action content-see other doc | |
| DateCreated | DateTime | Read-Only | |
| DateModified | DateTime | Read-Only |
Action Type enumeration
SHARE
Style
The Style is a free text zone, to be interpreted and understood by the Enriched Images searcher. Onprint smartphone application understands a Json string built as follows. There are 3 parts: the model (identifier so that the app knows how to parse it), the button style (css-like properties, written in Json), and the text style (css-like in Json too).
{
"model":"ONPrint-V2.0",
"button":{
"background-color":"#14d22c ",
"opacity":0.6
},
"text":{
"color":"#ffffff ",
"font-weight":"normal",
"font-style":"normal",
"opacity":1
}
}
LanguageCode, NodeId are mandatory. Node must be a Document, Image or Zone and have a Title for the provided language (even if it is an empty string). If the action type is empty, it will be set to RAW.
Can be sent independently: Content, IconId, LanguageCode, Name, NodeId, Order, Priority, Style, Type.
If the Action Type is patched, then the Content must be provided too, and reverse.
The DocumentLanguage is an association between an existing document and an existing language. When creating a new document, a DocumentLanguage is automatically created, with the default language of the document.
| Property | Type |
|---|---|
| DocumentId | Guid |
| LanguageCode | String |
DocumentId and LanguageCode are mandatory.
This resource corresponds to the languages in use in the platform. It is read-only.
| Property | Type | Description |
|---|---|---|
| Code | String | |
| Name | String | |
| Region | String | |
| Zone | String | Geographic zone |
Icons are associated to an action, but can be set at any node level. This will allow inheritance and default settings for the documents within a node.
| Property | Type | Comment |
|---|---|---|
| Id | Guid | Read-Only, generated |
| NodeId | Guid | |
| Name | String | |
| Tags | String | Comma-separated values in a string |
| Url | String | Read-Only |
The request body must be Multipart (multipart/form-data). The content is a File data and a Form data.
The icon image size must be maximum 64x64 pixel.
Contains the Json query object that goes with the content. It’s an Icon resource, named “icon”. NodeId is mandatory. Example:
{
"NodeId": "07b307ea-7253-4114-9ca1-5e367355df4a ",
"Name": "MyIcon",
"Tags": "work, telephone, call"
}
The PUT function needs the IconId as a parameter in the path: PUT api/Icons?iconId=…, and then a file (multipart, as for POST). The role of the PUT function here is just to replace the file. It will not be possible to modify the icon resource. To do so, a PATCH will have to be used.
Can be sent independently: NodeId, Name, Tags.
A title is associated to an image, document or zone, and a language. It is the title of the element that will be recognized. A title at a higher level than an image will be the default title for the children that are not overridden.
The methods will fail if the node type is other than image, document or zone.
| Property | Type |
|---|---|
| NodeId | Guid |
| LanguageCode | String |
| Value | String |
| Style | String |
Title Style
The Style is a free text zone, to be interpreted and understood by the Enriched Images searcher. See its description and example in the Action part.
The POST method is used to create default titles in parent nodes (folders, organizations). Under a document (for a document, image or zone), titles are created either at the document / image / zone creation, or by using the DocumentLanguage resource, using the PUT method with the language. Then, to edit the titles under the document, a PUT will have to be done on each node.
LanguageCode, NodeId, Value are mandatory.
Value is mandatory. LanguageCode and NodeId can’t be modified.
Can be sent independently: Style, Value.
A Zone is a sub part of an image which can be enriched independently. Creating a zone in an image will deactivate the parent image and activate the child zone. Actions of the original image become global to every zone.
| Property | Type | Description | Comment |
|---|---|---|---|
| Id | Guid | Read-Only, generated | |
| ImageId | Guid | ||
| Height | Int | Percentage of image size | |
| Width | Int | Percentage of image size | |
| PositionX | Int | Percentage of image size | |
| PositionY | Int | Percentage of image size | |
| Status | String | See Image status | Read-Only |
| Name | String | ||
| ActionCount | Int | Read-Only | |
| Order | Int | Order in image | |
| AutoTrigger | Bool? | Auto trigger of the action. Only if 1 action | |
| SmallThumbnail | String | 100px thumbnail | Read-Only |
| BigThumbnail | String | 700px thumbnail | Read-Only |
| DateCreated | DateTime | Read-Only | |
| DateModified | DateTime | Read-Only |
ImageId, PositionX, PositionY, Width, Height are mandatory.
PositionX, PositionY, Width, Height are mandatory. ImageId can’t be modified.
Can be sent independently: ActionStyle, AutoTrigger, Height, Name, PositionX, PositionY, TitleStyle, Width.
ImageAndZones is an intermediary resource that combines an image with its children zones. It can be accessed the same way as an image, but will have no interest if the image has no zone. This resource is read-only; manipulating zones is directly done through the Zone resource.
| Property | Type | Description |
|---|---|---|
| Id | Guid | |
| DocumentId | Guid | |
| Status | String | See Image status enumeration |
| Name | String | |
| ActionCount | Int | |
| ZoneCount | Int | |
| Order | Int | Order in document |
| AutoTrigger | Bool | Auto trigger of the action. Only if 1 action |
| SmallThumbnail | String | 100px thumbnail |
| BigThumbnail | String | 700px thumbnail |
| DateCreated | DateTime | |
| DateModified | DateTime | |
| Zones | List |
Zone list |
All the files related to a document: thumbnails and originals. The files are created at the document creation, and can be modified when modifying a document. This endpoint is read-only.
This resource is a full image used for recognition and getting actions associated to an image. It contains everything that is needed to use onprint from a mobile device.
| Property | Type | Description |
|---|---|---|
| Id | Guid | |
| BigThumbnailUrl | String | Big thumbnail URL (700px) |
| LanguageCode | String | |
| Title | String | Image title |
| DocumentId | Guid | |
| SessionId | String | Session Id: is set by the server |
| Order | Int | Image order in document |
| AutoTrigger | Bool | Auto trigger of the action Only if 1 action |
| TitleStyle | String | |
| Data | String | This field will always be empty, except when you scan a Picture, therefore you will have no Title, no Actions, no LanguageCode, no Styles. |
| Actions | List |
Read-Only resource, only contained in EnrichedImages.
| Property | Type | Description |
|---|---|---|
| Id | Guid | |
| Icon | String | Icon URL |
| Priority | Int | |
| Order | Int | |
| Name | String | |
| Style | String | |
| Type | String | See action type enumeration |
| Content | String |
To use any method for this resource, the following headers are required:
| Header | Mandatory? |
|---|---|
| SessionId | |
| ApplicationInstanceId | |
| ApplicationName | * |
| ApplicationVersion | * |
| ApiKey | * |
| DeviceName | * |
| DeviceSystemVersion | * |
| DeviceSystemVersionName | |
| SdkName | |
| SdkVersion | * |
| DeviceConnectivity | |
| DeviceScreenDiagonal | |
| DeviceScreenHeight | |
| DeviceScreenWidth |
If SessionId is null, it will be initialized by the server and given back in the EnrichedImage.
The POST method here is used as a search query, to search an image using image recognition. The request body content type must be Multipart (multipart/form-data). The content is made of a File data and a Form data.
Contains the image file of the picture taken (image/jpeg content type). The picture can be compressed, put in black&white and pre-treated to ease image recognition.
Contains the Json query object that goes with the content. The parameter only contains one property: Language (string) containing a language code. The form data name is “query”. Example:
{
"Language":"fr-FR"
}
The response is the enriched image with localized actions. Here is an example:
{
"Id": "712816b1-ae76-47fb-801f-a54b49378fb5",
"BigThumbnailUrl": "http://toto.com/bigthumb.jpg",
"LanguageCode": "fr-FR",
"Title": "Tout sur les Poissons",
"DocumentId": "07b307ea-7253-4114-9ca1-5e367355df4a",
"SessionId": "140cc120-e78a-4039-aef4-1b4b20436a58",
"Order": 1,
"AutoTrigger": true,
"Actions": [{
"Id": "1e60ce69-32e8-45b7-8655-36a1361ce4bc",
"Icon": "http://toto.com/icon.jpg",
"Priority": 2,
"Order": 8,
"Name": "Nous rejoindre",
"Type": "URL",
"Content": "{
\"Url\": \"http://www.onprint.com\",
\"IsEmbeddedWebView\": \"true\",
\"IsAnonymousURL\": \"true\",
\“ContentType\”:\”text/html\”}"
}]
}
The content parameter types are described in another document.
A click is an event resource that is used to track a click of a user on a given action. The most common use case is the smartphone application: the click is called after an image recognition and action listing, when the user taps on an action. The click is stateless, write-only.
To use this method, the following headers are required:
| Header | Mandatory? |
|---|---|
| SessionId | * |
| ApiKey | * |
If SessionId is null, it will be initialized by the server.
The PUT method is simply called with the Action identifier in the URL: PUT /api/clicks?actionId=…
Through this resource you can access information about the search requests made against a document.
| Property | Type | Description |
|---|---|---|
| RequestTime | DateTime | |
| DeviceSystemVersion | String | |
| Language | String | Language code |
| Operating System | String | |
| ImageOrder | Int | Order of image in document |
| DocumentName | String | |
| Host | String | IP of caller |
| Clicks | List |
Clicks associated to the match |
Read-Only resource, only contained in Matches.
| Property | Type | Description |
|---|---|---|
| ClickTime | DateTime | |
| Host | String | IP of caller |
| ActionName | String | |
| ActionOrder | Int | Order of action in image |
| ActionType | String | |
| ActionId | Guid |
Roles are associated to rights management and permissions of a user. It is not possible to add a new role. The PUT method allows to associate a User to a known role.
| Property | Type | Description |
|---|---|---|
| Role | String | Nom du rôle* |
Role enumeration
The PUT method needs the userId and the role name as parameters in the path, and no content: PUT api/Users/{userId}/Roles/{role}. Example: PUT /api/Users/123456/Roles/Designer
Management of the platform users. A user is attached to an organization.
| Property | Type | Description | Comment |
|---|---|---|---|
| Id | Guid | Read-Only, generated | |
| OrganizationId | Guid | ||
| UserName | String | ||
| String | e-mail address | ||
| FirstName | String | ||
| LastName | String | ||
| Password | String | ||
| Status | String | (see below) | |
| Gender | String | (see below) |
User Status enumeration
Active
User Gender enumeration
OrganizationId, Mail are mandatory. If provided Username is NULL, Mail address will be copied into Username.
OrganizationId, Mail are mandatory. PUT does not update Password. If provided Username is NULL, Mail address will be copied into Username.
Can be sent independently: Status, Password.
An organization’s account, created after the organization creation. RemainingCredit depends on the contract type. The other fields are counters. This resource is read-only.
| Property | Type | Description |
|---|---|---|
| OrganizationId | Guid | |
| ValidityDate | DateTime | End of contract date |
| ActivePages | Int | Number of active pages |
| ActivationCumul | Int | Number of pages that have been activated at least once |
| AccountType | String | (see below) |
| RemainingCredit | int | Remaining pages to activate |
Account Type enumeration
A credit is an event resource that means a transaction between a source and a target. The source is the organization of the user that is logged in, the target is the organization identifier given in the Json parameter. To give or take credits, the user must have sufficient rights on the source and on the target organizations. The credit transaction is stateless, write-only.
| Property | Type |
|---|---|
| OrganizationId | Guid |
| Amount | Guid |
| Direction | String |
Credit Direction enumeration
The Logo is associated to an organization. It is used for platform client display. It can only be set or deleted from here, and its URL is available in the organization resource properties.
The request body content type must be Multipart (multipart/form-data). It needs the OrganizationId as a parameter in the path: PUT api/Logo/{id} and a File Data. In File data, the logo can be any image type (png, jpg, gif).
An organization represents a customer (company or individual). It’s the main node of a document hierarchy.
| Property | Type | Description | Comment |
|---|---|---|---|
| Id | Guid | Read-Only, generated | |
| ParentId | Guid? | NodeId (parent) | |
| Logo | String | Logo URL | Read-Only |
| LanguageCode | String | ||
| Name | String | ||
| ApiKey | String | API Key, used for WebAPI calls | Read-Only |
| AccountType | String | See account type enumeration | Read-Only |
| MobileApiAuthorized | Bool | Mobile can reach the API | Read-Only |
| WebApiAuthorized | Bool | Any API access | Read-Only |
| IRProviderId | Guid | Id and access details of IR Provider | Read-Only |
| ActivationCumul | Int | See account resource | Read-Only |
| DeactivationCumul | Int | Read-Only | |
| TotalDebit | Int | Read-Only | |
| TotalCredit | Int | Read-Only | |
| DateCreated | DateTime | Read-Only | |
| DateModified | DateTime | Read-Only | |
| PicturesCount | Int? | Pictures Counter, only for organizations in Pictures mode. Updated when option GetPicturesCount is True in GET Organizations/Id. | Read-Only |
LanguageCode, Name, ParentId are mandatory.
Can be sent independently: LanguageCode, Name, ParentId.
AccountType, IRProviderId, MobileApiAuthorized and WebApiAuthorized are special fields that require ONprint input and cannot be set / modified. Contact us for more information.
Folder management.
| Property | Type | Description | Comment |
|---|---|---|---|
| Id | Guid | Read-Only, generated | |
| ParentId | Guid | NodeId | |
| Name | String | ||
| DateCreated | DateTime | Read-Only | |
| DateModified | DateTime | Read-Only |
Name and ParentId are mandatory.
Can be sent independently: Name, ParentId.
A node is an element of arborescence that hierarchically organizes Organizations, Folders, Documents, Images and Zones. It contains no information but the hierarchy of nodes. Nodes are systematically created among with Organizations, Folders, Documents, Images and Zones.
| Property | Type |
|---|---|
| Id | Guid |
| Type | String |
| ParentId | Guid |
| Name | String |
Node Type enumeration
Properties define default behavior for nodes. Today it only concerns default Icon or default Style. Behavior of properties is different for icon properties and style properties. For an icon, it is only stored, not used by the server and not provided in the list of icons in the node. For a style, the information is used by the server. The style is automatically set for all the children titles or actions, existing or new, when there is no other defined style in the hierarchy.
| Property | Type | Comment |
|---|---|---|
| Id | Guid | Read-Only, generated |
| NodeId | Guid | |
| Type | String | |
| Name | String | |
| Value | String |
Property Type enumeration
Icon
Property Name constraint
If Property Type is “Style”, Property name must be one of the following. It indicates whether the property sets a default ActionStyle or a default TitleStyle:
NodeId, Type and Name are mandatory.
Can be sent independently: Name, Value.
History Node Management.
| Property | Type |
|---|---|
| Date | DateTime |
| User | String |
| Operation * | String |
Sometimes, you will only need the Platform to identify an image, not to enrich it with actions, languages and styles. There are entry points for that. You only need a login, an OrganizationId (you get it when you log in), and an API Key for searching. This part is optimized for High Volumes / High Speed image recognition. No image is stored in the platform, and data is indexed in a fast database.
A Picture is a simple, single Image. It is not compatible with the whole Node hierarchy and cannot be into a Document, nor listed in a Folder. There cannot be Zones in it. It is only linked to an Organization.
| Property | Mandatory? | Type | Description | Comment |
|---|---|---|---|---|
| Id | String | Picture Id in the platform. | Read-Only, generated | |
| _objectId | String | Internal Id, useful for pagination (see ) | Read-Only, generated | |
| Name | * | String | Picture name. Can be your own identifier | |
| Data | String | Picture metadata. You can put whatever you want, in any format. | ||
| OrganizationId | * | String | Organization's Id. Pictures will be listed under it. | |
| BigThumbnailUrl | String | URL of the Picture's Thumbnail. (only for display) | Read-Only, generated | |
| SessionId | String | Session identifier that you can use to link events to the IR. | Read-Only, generated | |
| RecognitionScore | String | Score of the image recognition, regarding the query image. | Read-Only | |
| Keywords | String[] | Keywords attached to the picture, to filter searches. |
The POST method is used to create a picture by sending the image file and its properties. The request body content type must be Multipart (multipart/form-data). The content is made of a File data (file) and a Form data (picture).
The image itself. It can be a JPEG, PNG, or GIF image. The MIME type has to be given in the file content type.
Contains a Picture object. The form data name is picture. Name and OrganizationId are mandatory. If you don't know where to find an OrganizationId, yours is in the token when you log in.
Calling PUT /api/Pictures with an existing updated Picture in the body will only update its Name, Data and Keywords.
Calling PATCH /api/Pictures with an existing updated Picture in the body can update its Name, Data and Keywords, if a value is entered for each.
The POST method on SEARCH is used to query the image for recognition. The request body content type must be Multipart (multipart/form-data). The content is made of a File data (file) and a Form data (query), currently left empty. This method does not require authentication but the following headers:
| Header | Mandatory? |
|---|---|
| ApplicationInstanceId | |
| ApplicationName | * |
| ApplicationVersion | * |
| ApiKey | * |
| DeviceName | * |
| DeviceSystemVersion | * |
| DeviceSystemVersionName | |
| SdkName | |
| SdkVersion | * |
| DeviceConnectivity | |
| DeviceScreenDiagonal | |
| DeviceScreenHeight | |
| DeviceScreenWidth |
The query image itself. It can be a JPEG, PNG, or GIF image. The MIME type has to be given in the file content type.
Please send also a query consisting of an empty form { }. The form data name is query. A query object to precise / filter results. Currently it consists of adding the picture's keywords as a Json:
{
Keywords:["keyword1", "keyword2"]
}
The Search returns a list of pictures matching the query image and, if there are, the keywords. Every matching Picture is returned with its RecognitionScore between 0 and 1, the highest being 1.