Welcome to openregistry.assets.basic’s documentation!¶
Please report any problems or suggestions for improvement either via the mailing list or the issue tracker.
Contents:
Overview¶
openregistry.assets.basic contains the description of the Registry Data Base.
Features¶
- Basic asset is a representation of an item.
- Procedure can be switched from draft status to pending.
- Basic assets are combined in lot, being marked as attached to that lot.
- The only currency (Value.currency) to be used is hryvnia (UAH).
Conventions¶
API accepts JSON or form-encoded content in requests. It returns JSON content in all of its responses, including errors. Only the UTF-8 character encoding is supported for both requests and responses.
All API POST and PUT requests expect a top-level object with a single element in it named data. Successful responses will mirror this format. The data element should itself be an object, containing the parameters for the request.
If the request was successful, we will get a response code of 201 indicating the object was created. That response will have a data field at its top level, which will contain complete information on the new auction, including its ID.
If something went wrong during the request, we’ll get a different status code and the JSON returned will have an errors field at the top level containing a list of problems. We look at the first one and print out its message.
Project status¶
The project has pre alpha status.
The source repository for this project is on GitHub: https://github.com/openprocurement/openregistry.api
API stability¶
API is relatively stable. The changes in the API are communicated via Open Procurement API maillist.
Change log¶
0.1¶
Not Released
- Set up general build, testing, deployment, and ci framework.
- Creating/modifying asset
Next steps¶
You might find it helpful to look at the Tutorial, or the Command Reference.
Data Standard¶
Data standard is modelled along the Open Contracting Standard with extensions in areas that were not covered by it.
Basic Asset¶
Schema¶
id: | string, auto-generated, read-only |
||||||
---|---|---|---|---|---|---|---|
assetID: | string, auto-generated, read-only The asset identifier to refer it to in the paper documentation. OpenContracting Description: AssetID is included to make the flattened data structure more convenient. |
||||||
date: | string, auto-generated, read-only The date of asset creation/undoing. |
||||||
dateModified: | string, auto-generated, read-only OpenContracting Description: Date when the asset was last modified. |
||||||
mode: | optional The additional parameter with a value |
||||||
status: | string, required The asset status within the Registry. |
||||||
value: | Value, required Estimated asset value. |
||||||
relatedLot: | string, required in active status ID of the related Lot. |
||||||
assetType: | string, required Type of the given asset. |
||||||
title: | string, multilingual
Oprionally can be mentioned in English/Russian. |
||||||
description: | string, multilingual, optional OpenContracting Description: A description of the goods, services to be provided.
|
||||||
documents: | OpenContracting Description: All related documents and attachments. |
||||||
assetCustodian: | Organization, required The entity managing the asset. |
||||||
classification: | Classification, required The primary classification for the asset. It is required for classification.scheme to be CAV. The classification.id should be valid CAV code. |
||||||
additionalClassifications: | |||||||
Array of Classification objects, optioanl OpenContracting Description: An array of additional classifications for the item. See the itemClassificationScheme codelist for common options to use in OCDS. This may also be used to present codes from an internal classification scheme. The possible additional classifiers are CPVS and koatuu. |
|||||||
unit: | Unit, required OpenContracting Description: Description of the unit which the good comes in e.g. hours, kilograms. Made up of a unit name, and the value of a single unit. |
||||||
quantity: | decimal, required OpenContracting Description: The number of units required. |
||||||
location: | dictionary Geographical coordinates of the location. Element consists of the following items:
|
Classification¶
Schema¶
scheme: | string OpenContracting Description: A classification should be drawn from an existing scheme or list of codes. This field is used to indicate the scheme/codelist from which the classification is drawn. For line item classifications, this value should represent a known Item Classification Scheme wherever possible. |
---|---|
id: | string OpenContracting Description: The classification code drawn from the selected scheme. |
description: | string OpenContracting Description: A textual description or title for the code. |
uri: | uri OpenContracting Description: A URI to identify the code. In the event individual URIs are not available for items in the identifier scheme this value should be left blank. |
Unit¶
Schema¶
code: | string, required UN/CEFACT Recommendation 20 unit code. |
---|---|
name: | string OpenContracting Description: Name of the unit |
Value¶
Schema¶
amount: | float, required Should be positive. |
---|---|
currency: | string, required OpenContracting Description: The currency in 3-letter ISO 4217 format. |
valueAddedTaxIncluded: | |
bool, required |
Organization¶
Schema¶
name: | string, multilingual Name of the organization. |
---|---|
identifier: |
The primary identifier for this organization. |
additionalIdentifiers: | |
List of Identifier objects |
|
address: | Address, required |
contactPoint: | ContactPoint, required |
Identifier¶
Schema¶
scheme: | string OpenContracting Description: Organization identifiers be drawn from an existing identification scheme. This field is used to indicate the scheme or codelist in which the identifier will be found. This value should be drawn from the Organization Identifier Scheme. |
---|---|
id: | string, required OpenContracting Description: The identifier of the organization in the selected scheme. The allowed codes are the ones found in “Organisation Registration Agency” codelist of IATI Standard with addition of UA-EDR code for organizations registered in Ukraine (EDRPOU and IPN). |
legalName: | string, multilingual OpenContracting Description: The legally registered name of the organization. Full legal name (e.g. Nadra Bank). |
uri: | uri OpenContracting Description: A URI to identify the organization, such as those provided by Open Corporates or some other relevant URI provider. This is not for listing the website of the organization: that can be done through the url field of the Organization contact point. |
Address¶
Schema¶
streetAddress: | string OpenContracting Description: The street address. For example, 1600 Amphitheatre Pkwy. |
---|---|
locality: | string OpenContracting Description: The locality. For example, Mountain View. |
region: | string OpenContracting Description: The region. For example, CA. |
postalCode: | string OpenContracting Description: The postal code. For example, 94043. |
countryName: | string, multilingual, required OpenContracting Description: The country name. For example, United States. |
ContactPoint¶
Schema¶
name: | string, multilingual, required OpenContracting Description: The name of the contact person, department, or contact point, for correspondence relating to this contracting process. |
---|---|
email: | OpenContracting Description: The e-mail address of the contact point/person. |
telephone: | string OpenContracting Description: The telephone number of the contact point/person. This should include the international dialling code. |
faxNumber: | string OpenContracting Description: The fax number of the contact point/person. This should include the international dialling code. |
url: | URL OpenContracting Description: A web address for the contact point/person. |
Either email or telephone field has to be provided.
Document¶
Schema¶
id: | string, auto-generated |
---|---|
documentType: | string |
title: | string, multilingual OpenContracting Description: The document title. |
description: | string, multilingual OpenContracting Description: A short description of the document. In the event the document is not accessible online, the description field can be used to describe arrangements for obtaining a copy of the document. |
format: | string OpenContracting Description: The format of the document taken from the IANA Media Types code list, with the addition of one extra value for ‘offline/print’, used when this document entry is being used to describe the offline publication of a document. |
url: | string, auto-generated OpenContracting Description: Direct link to the document or attachment. |
datePublished: | string, Date OpenContracting Description: The date on which the document was first published. |
dateModified: | string, Date OpenContracting Description: Date that the document was last modified |
language: | string OpenContracting Description: Specifies the language of the linked document using either two-digit ISO 639-1, or extended BCP47 language tags. |
documentOf: | string Possible values are:
|
relatedItem: | string |
Tutorial¶
Exploring basic rules¶
Let’s try exploring the /assets endpoint:
GET /api/0.1/assets HTTP/1.0
Authorization: Basic YnJva2VyOg==
Host: lb.api-sandbox.registry.ea.openprocurement.net
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"next_page": {
"path": "/api/0.1/assets?offset=",
"uri": "http://lb.api-sandbox.registry.ea.openprocurement.net/api/0.1/assets?offset=",
"offset": ""
},
"data": []
}
Just invoking it reveals empty set.
Now let’s attempt creating some asset:
POST /api/0.1/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 4
Content-Type: application/x-www-form-urlencoded
Host: lb.api-sandbox.registry.ea.openprocurement.net
415 Unsupported Media Type
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"status": "error",
"errors": [
{
"description": "Content-Type header should be one of ['application/json']",
"location": "header",
"name": "Content-Type"
}
]
}
Error states that the only accepted Content-Type is application/json.
Let’s satisfy the Content-type requirement:
POST /api/0.1/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 4
Content-Type: application/json
Host: lb.api-sandbox.registry.ea.openprocurement.net
422 Unprocessable Entity
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"status": "error",
"errors": [
{
"description": "No JSON object could be decoded",
"location": "body",
"name": "data"
}
]
}
Error states that no data has been found in JSON body.
Creating asset¶
Let’s create asset with the minimal (only required) data set:
POST /api/0.1/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 1535
Content-Type: application/json
Host: lb.api-sandbox.registry.ea.openprocurement.net
{
"data": {
"status": "draft",
"assetType": "basic",
"classification": {
"scheme": "CAV",
"id": "39513200-3",
"description": "Земельні ділянки"
},
"title": "Земля для космодрому",
"value": {
"currency": "UAH",
"amount": 100
},
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"countryName": "Україна",
"postalCode": "01220",
"region": "м. Київ",
"streetAddress": "вул. Банкова, 11, корпус 1",
"locality": "м. Київ"
}
},
"address": {
"countryName": "Україна",
"postalCode": "79000",
"region": "м. Київ",
"streetAddress": "вул. Банкова 1",
"locality": "м. Київ"
},
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
201 Created
Content-Type: application/json
Location: http://lb.api-sandbox.registry.ea.openprocurement.net/api/0.1/assets/f7d85ded1544424d82a3473f9467f80f
X-Content-Type-Options: nosniff
{
"access": {
"token": "1803ee39a2164a3dacd9aee5e581aa7d"
},
"data": {
"status": "draft",
"assetType": "basic",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"title": "Земля для космодрому",
"assetID": "UA-2017-08-16-000001",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:13.847230+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:13.844875+03:00",
"id": "f7d85ded1544424d82a3473f9467f80f",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
PATCH /api/0.1/assets/f7d85ded1544424d82a3473f9467f80f?acc_token=1803ee39a2164a3dacd9aee5e581aa7d HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 31
Content-Type: application/json
Host: lb.api-sandbox.registry.ea.openprocurement.net
{
"data": {
"status": "pending"
}
}
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"data": {
"status": "pending",
"assetType": "basic",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"title": "Земля для космодрому",
"assetID": "UA-2017-08-16-000001",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:13.882146+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:13.882146+03:00",
"id": "f7d85ded1544424d82a3473f9467f80f",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
Success! Now we can see that new object was created. Response code is 201 and Location response header reports the location of the created object. The body of response reveals the information about the created asset: its internal id (that matches the Location segment), its official assetID and dateModified datestamp stating the moment in time when asset was last modified. Pay attention to the assetType. Note that asset is created with pending status.
Let’s access the URL of the created object (the Location header of the response):
GET /api/0.1/assets/f7d85ded1544424d82a3473f9467f80f HTTP/1.0
Authorization: Basic YnJva2VyOg==
Host: lb.api-sandbox.registry.ea.openprocurement.net
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"data": {
"status": "pending",
"assetType": "basic",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"title": "Земля для космодрому",
"assetID": "UA-2017-08-16-000001",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:13.882146+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:13.882146+03:00",
"id": "f7d85ded1544424d82a3473f9467f80f",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
We can see the same response we got after creating asset.
Let’s see what listing of assets reveals us:
GET /api/0.1/assets HTTP/1.0
Authorization: Basic YnJva2VyOg==
Host: lb.api-sandbox.registry.ea.openprocurement.net
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"next_page": {
"path": "/api/0.1/assets?offset=2017-08-16T18%3A36%3A13.882146%2B03%3A00",
"uri": "http://lb.api-sandbox.registry.ea.openprocurement.net/api/0.1/assets?offset=2017-08-16T18%3A36%3A13.882146%2B03%3A00",
"offset": "2017-08-16T18:36:13.882146+03:00"
},
"data": [
{
"id": "f7d85ded1544424d82a3473f9467f80f",
"dateModified": "2017-08-16T18:36:13.882146+03:00"
}
]
}
We do see the internal id of a asset (that can be used to construct full URL by prepending http://lb.api-sandbox.registry.openprocurement.net/api/0/assets/) and its dateModified datestamp.
The previous asset contained only required fields. Let’s try creating asset with more data (asset has status created):
POST /api/0.1/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 1516
Content-Type: application/json
Host: lb.api-sandbox.registry.ea.openprocurement.net
{
"data": {
"assetType": "basic",
"classification": {
"scheme": "CAV",
"id": "39513200-3",
"description": "Земельні ділянки"
},
"title": "Земля для космодрому",
"value": {
"currency": "UAH",
"amount": 100
},
"unit": {
"code": "39513200-3",
"name": "item"
},
"address": {
"countryName": "Україна",
"postalCode": "79000",
"region": "м. Київ",
"streetAddress": "вул. Банкова 1",
"locality": "м. Київ"
},
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"countryName": "Україна",
"postalCode": "01220",
"region": "м. Київ",
"streetAddress": "вул. Банкова, 11, корпус 1",
"locality": "м. Київ"
}
},
"quantity": 5
}
}
201 Created
Content-Type: application/json
Location: http://lb.api-sandbox.registry.ea.openprocurement.net/api/0.1/assets/bb2d3063c01346cb8a7f9f747dbd02b6
X-Content-Type-Options: nosniff
{
"access": {
"token": "a14cec8e4d3f4888a27f31fb0b54ee25"
},
"data": {
"status": "draft",
"assetType": "basic",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"title": "Земля для космодрому",
"assetID": "UA-2017-08-16-000002",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:14.032506+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:14.030468+03:00",
"id": "bb2d3063c01346cb8a7f9f747dbd02b6",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
And again we have 201 Created response code, Location header and body with extra id, assetID, and dateModified properties.
Let’s check what asset registry contains:
GET /api/0.1/assets HTTP/1.0
Authorization: Basic YnJva2VyOg==
Host: lb.api-sandbox.registry.ea.openprocurement.net
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"next_page": {
"path": "/api/0.1/assets?offset=2017-08-16T18%3A36%3A13.882146%2B03%3A00",
"uri": "http://lb.api-sandbox.registry.ea.openprocurement.net/api/0.1/assets?offset=2017-08-16T18%3A36%3A13.882146%2B03%3A00",
"offset": "2017-08-16T18:36:13.882146+03:00"
},
"data": [
{
"id": "f7d85ded1544424d82a3473f9467f80f",
"dateModified": "2017-08-16T18:36:13.882146+03:00"
}
]
}
And indeed we have 2 assets now.
Modifying Asset¶
Let’s update asset description:
PATCH /api/0.1/assets/f7d85ded1544424d82a3473f9467f80f?acc_token=1803ee39a2164a3dacd9aee5e581aa7d HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 347
Content-Type: application/json
Host: lb.api-sandbox.registry.ea.openprocurement.net
{
"data": {
"description": "Земельні ділянки із великими покладами благородних металів"
}
}
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"data": {
"status": "pending",
"assetType": "basic",
"description": "Земельні ділянки із великими покладами благородних металів",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"title": "Земля для космодрому",
"assetID": "UA-2017-08-16-000001",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:14.133838+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:13.882146+03:00",
"id": "f7d85ded1544424d82a3473f9467f80f",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
We see the added properies have merged with existing asset data. Additionally, the dateModified property was updated to reflect the last modification datestamp.
Checking the listing again reflects the new modification date:
GET /api/0.1/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Host: lb.api-sandbox.registry.ea.openprocurement.net
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"next_page": {
"path": "/api/0.1/assets?offset=2017-08-16T18%3A36%3A14.133838%2B03%3A00",
"uri": "http://lb.api-sandbox.registry.ea.openprocurement.net/api/0.1/assets?offset=2017-08-16T18%3A36%3A14.133838%2B03%3A00",
"offset": "2017-08-16T18:36:14.133838+03:00"
},
"data": [
{
"id": "f7d85ded1544424d82a3473f9467f80f",
"dateModified": "2017-08-16T18:36:14.133838+03:00"
}
]
}
Deleting Asset¶
Let’s delete asset:
PATCH /api/0.1/assets/f7d85ded1544424d82a3473f9467f80f?acc_token=1803ee39a2164a3dacd9aee5e581aa7d HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 31
Content-Type: application/json
Host: lb.api-sandbox.registry.ea.openprocurement.net
{
"data": {
"status": "deleted"
}
}
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"data": {
"status": "deleted",
"assetType": "basic",
"description": "Земельні ділянки із великими покладами благородних металів",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"title": "Земля для космодрому",
"assetID": "UA-2017-08-16-000001",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:14.273050+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:14.273050+03:00",
"id": "f7d85ded1544424d82a3473f9467f80f",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
Integration with lots¶
GET /api/0.1/assets/11ff5b04c97040c1882f0565ab43381a HTTP/1.0
Authorization: Basic Ym90Og==
Host: lb.api-sandbox.registry.ea.openprocurement.net
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"data": {
"status": "active",
"relatedLot": "140e37e9351d461bb5f6765f6f3ba5a9",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"assetType": "basic",
"assetID": "UA-2017-08-16-000001",
"title": "Земля для космодрому",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:14.510454+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:14.510454+03:00",
"id": "11ff5b04c97040c1882f0565ab43381a",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
GET /api/0.1/assets/11ff5b04c97040c1882f0565ab43381a HTTP/1.0
Authorization: Basic Ym90Og==
Host: lb.api-sandbox.registry.ea.openprocurement.net
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"data": {
"status": "pending",
"relatedLot": "140e37e9351d461bb5f6765f6f3ba5a9",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"assetType": "basic",
"assetID": "UA-2017-08-16-000001",
"title": "Земля для космодрому",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:14.549945+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:14.549945+03:00",
"id": "11ff5b04c97040c1882f0565ab43381a",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
GET /api/0.1/assets/11ff5b04c97040c1882f0565ab43381a HTTP/1.0
Authorization: Basic Ym90Og==
Host: lb.api-sandbox.registry.ea.openprocurement.net
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"data": {
"status": "complete",
"relatedLot": "33f5b2a323034850bc268e4af669358b",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"assetType": "basic",
"assetID": "UA-2017-08-16-000001",
"title": "Земля для космодрому",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:14.667379+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:14.667379+03:00",
"id": "11ff5b04c97040c1882f0565ab43381a",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
Retrieving Asset Information¶
Getting list of all assets¶
-
GET
/assets
¶ Getting list of all assets.
Example request:
GET api/0/assets HTTP/1.1 Host: lb.api-sandbox.registry.ea.openprocurement.net
Example response:
200 OK Content-Type: application/json X-Content-Type-Options: nosniff { "next_page": { "path": "/api/0.1/assets?offset=2017-08-14T13%3A35%3A31.474578%2B03%3A00", "uri": "http://lb.api-sandbox.registry.ea.openprocurement.net/api/0.1/assets?offset=2017-08-14T13%3A35%3A31.474578%2B03%3A00", "offset": "2017-08-14T13:35:31.474578+03:00" }, "data": [ { "id": "2f684c8a57f447768a5a451e2e8e5892", "dateModified": "2017-08-14T13:35:31.474578+03:00" }, { "id": "1f28428a37f457768a5a451e2e8e5892", "dateModified": "2017-08-15T13:35:31.474578+03:00" } ] }
Query Parameters: - offset – offset number
- limit – limit number. default is 100
Request Headers: - Authorization – optional OAuth token to authenticate
Status Codes: - 200 OK – no error
- 404 Not Found – endpoint not found
Sorting¶
Assets returned are sorted by modification time.
Limiting number of Assets returned¶
You can control the number of data entries in the assets feed (batch size) with limit parameter. If not specified, data is being returned in batches of 100 elements.
Batching¶
The response contains next_page element with the following properties:
offset: | This is the parameter you have to add to the original request you made to get next page. |
---|---|
path: | This is path section of URL with original parameters and offset parameter added/replaced above. |
uri: | The full version of URL for next page. |
If next page request returns no data (i.e. empty array) then there is little sense in fetching further pages.
Synchronizing¶
It is often necessary to be able to syncronize central database changes with other database (we’ll call it “local”). The default sorting “by modification date” together with Batching mechanism allows one to implement synchronization effectively. The synchronization process can go page by page until there is no new data returned. Then the synchronizer has to pause for a while to let central database register some changes and attempt fetching subsequent page. The next_page guarantees that all changes from the last request are included in the new batch.
The safe frequency of synchronization requests is once per 5 minutes.
Reading the individual asset information¶
-
GET
/assets/{uuid4:id}
¶ Getting asset details.
Example request:
GET /api/0.1/assets/2f684c8a57f447768a5a451e2e8e5892 HTTP/1.0 Host: lb.api-sandbox.registry.ea.openprocurement.net
Example response:
200 OK Content-Type: application/json { "data": { "status": "pending", "assetType": "basic", "classification": { "scheme": "CAV", "description": "Земельні ділянки", "id": "39513200-3" }, "title": "Земля для космодрому", "assetID": "UA-2017-08-14-000001", "value": { "currency": "UAH", "amount": 100.0, "valueAddedTaxIncluded": true }, "dateModified": "2017-08-14T13:35:31.474578+03:00", "owner": "broker", "assetCustodian": { "contactPoint": { "name": "Державне управління справами", "telephone": "0440000000" }, "identifier": { "scheme": "UA-EDR", "id": "00037256", "uri": "http://www.dus.gov.ua/" }, "name": "Державне управління справами", "address": { "postalCode": "01220", "countryName": "Україна", "streetAddress": "вул. Банкова, 11, корпус 1", "region": "м. Київ", "locality": "м. Київ" } }, "address": { "postalCode": "79000", "countryName": "Україна", "streetAddress": "вул. Банкова 1", "region": "м. Київ", "locality": "м. Київ" }, "date": "2017-08-14T13:35:31.472331+03:00", "id": "2f684c8a57f447768a5a451e2e8e5892", "unit": { "code": "39513200-3", "name": "item" }, "quantity": 5 } }
Request Headers: - Authorization – optional OAuth token to authenticate
Status Codes: - 200 OK – no error
- 404 Not Found – asset not found
Authentication¶
Some of the API requests (especially the ones that are read-only GET requests) do not require any authenication. The other ones, that modify data into the database, require broker authentication via API key. Additionally, owner tokens are issued to facilitate multiple actor roles upon object creation.
API keys¶
API key is username to use with Basic Authenication scheme.
Owner tokens¶
Getting token¶
The token is issued when object is created in the database:
POST /api/0.1/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 1516
Content-Type: application/json
Host: lb.api-sandbox.registry.ea.openprocurement.net
{
"data": {
"assetType": "basic",
"classification": {
"scheme": "CAV",
"id": "39513200-3",
"description": "Земельні ділянки"
},
"title": "Земля для космодрому",
"value": {
"currency": "UAH",
"amount": 100
},
"unit": {
"code": "39513200-3",
"name": "item"
},
"address": {
"countryName": "Україна",
"postalCode": "79000",
"region": "м. Київ",
"streetAddress": "вул. Банкова 1",
"locality": "м. Київ"
},
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"countryName": "Україна",
"postalCode": "01220",
"region": "м. Київ",
"streetAddress": "вул. Банкова, 11, корпус 1",
"locality": "м. Київ"
}
},
"quantity": 5
}
}
201 Created
Content-Type: application/json
Location: http://lb.api-sandbox.registry.ea.openprocurement.net/api/0.1/assets/546aba419d944de29c4160d0a1cbf6ea
X-Content-Type-Options: nosniff
{
"access": {
"token": "20c787519afb4e18ad0c35bbed34cded"
},
"data": {
"status": "draft",
"assetType": "basic",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"title": "Земля для космодрому",
"assetID": "UA-2017-08-16-000001",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:05:56.036043+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:05:56.034096+03:00",
"id": "546aba419d944de29c4160d0a1cbf6ea",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
You can see the access with token in response. Its value can be used to modify objects further under “Owner role”.
Using token¶
You can pass access token in the following ways:
- acc_token URL query string parameter
- X-Access-Token HTTP request header
- access.token in the body of POST/PUT/PATCH request
See the example of the action with token passed as URL query string:
PATCH /api/0.1/assets/f7d85ded1544424d82a3473f9467f80f?acc_token=1803ee39a2164a3dacd9aee5e581aa7d HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 347
Content-Type: application/json
Host: lb.api-sandbox.registry.ea.openprocurement.net
{
"data": {
"description": "Земельні ділянки із великими покладами благородних металів"
}
}
200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"data": {
"status": "pending",
"assetType": "basic",
"description": "Земельні ділянки із великими покладами благородних металів",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"title": "Земля для космодрому",
"assetID": "UA-2017-08-16-000001",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:14.133838+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:13.882146+03:00",
"id": "f7d85ded1544424d82a3473f9467f80f",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
API in cluster mode¶
There is a cluster of several servers that synchronize data between each other. Client should always work with the same server to ensure consistency between separate requests to the CDB. That is why cookie is required while sending POST/PUT/PATCH/DELETE requests. Cookies provide server stickiness. You can get such cookie via GET request and then use it for POST/PUT/PATCH/DELETE.
If during operations the server requested by cookie went down or is unavailable, client will receive status code 412 of request and new cookie to use. Request should be repeated with new cookie.
Options¶
In addition to providing fields and their values in a request, you may also specify options to control how your request is interpreted and how the response is generated. For GET requests, options are specified as URL parameters prefixed with opt_. For POST or PUT requests, options are specified in the body, inside the top-level options object (a sibling of the data object). The option specified in the body overrides the opt_ one from URL parameter.
These options can be used in different combinations in a single request, though some of them may conflict in their impact on the response.
pretty: | ?opt_pretty options: { pretty: true } Provides the response in “pretty” output. In case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable to use this only during debugging. |
---|---|
jsonp: | ?opt_jsonp=myCallback Returns the output in JSON-P format instead of plain JSON. This allows requests to come from within browsers and work around the “same origin policy.” The function named as the value of the opt_jsonp parameter will be called with a single argument, a JavaScript object representing the response. |
fields: | ?opt_fields=comma,separated,field,list List of extra fields to include in response. |
Performance recommendations¶
Rate Control¶
“Aggressive” IP addresses can be restricted in the speed with which servers are processing CDB requests. In this case CDB will respond with status code 429 to the requests that returned faster than allowed.
Expected client response to such restriction is to repeat requests returned with 429 status code increasing the delay between individual requests sent to the CDB until requests become successful (2xx / 3xx responses).
Such CDB servers behavior is required in order to distribute server resources evenly between clients.
Responses¶
After processing API always provides response, reporting either success or failure.
Status Codes¶
In all cases, the API should return an HTTP Status Code that indicates the nature of the failure (see below), with a response body in JSON format containing additional information.
- 200
- Success. If data was requested, it will be available in the data field at the top level of the response body.
- 201
- Success (for object creation). Its information is available in the data field at the top level of the response body. The API URL where the object can be retrieved is also returned in the Location header of the response.
- 400
- Invalid request. This usually occurs because of a missing or malformed parameter. Check the documentation and the syntax of your request and try again.
- 401
- No authorization. A valid API key was not provided with the request, so the API could not associate a user with the request.
- 403
- Forbidden. The API key and request syntax was valid but the server is refusing to complete the request. This can happen if you are trying to read or write to objects or properties that you do not have access to.
- 404
- Not found. Either the request method and path supplied do not specify a known action in the API, or the object specified by the request does not exist.
- 412
- Precondition Failed. See API in cluster mode.
- 429
- Rate Limit Enforced. See Rate control.
- 500
- Server error. There was a problem on OpenProcurement’s end.
Success Response¶
Every successful get, create, update, replace request results in response that contains data attribute. That data attribute contains full JSON object representation after the operation. If some data were generated in the result of processing (like new object IDs, or modified date) they are present in the respose.
The listing requests result in similar responses, but instead of single object in data attribute, the JSON response contains collection of objects.
Example Success Response¶
Here is a response that describes asset
POST /api/0.1/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 1516
Content-Type: application/json
Host: lb.api-sandbox.registry.ea.openprocurement.net
{
"data": {
"assetType": "basic",
"classification": {
"scheme": "CAV",
"id": "39513200-3",
"description": "Земельні ділянки"
},
"title": "Земля для космодрому",
"value": {
"currency": "UAH",
"amount": 100
},
"unit": {
"code": "39513200-3",
"name": "item"
},
"address": {
"countryName": "Україна",
"postalCode": "79000",
"region": "м. Київ",
"streetAddress": "вул. Банкова 1",
"locality": "м. Київ"
},
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"countryName": "Україна",
"postalCode": "01220",
"region": "м. Київ",
"streetAddress": "вул. Банкова, 11, корпус 1",
"locality": "м. Київ"
}
},
"quantity": 5
}
}
201 Created
Content-Type: application/json
Location: http://lb.api-sandbox.registry.ea.openprocurement.net/api/0.1/assets/bb2d3063c01346cb8a7f9f747dbd02b6
X-Content-Type-Options: nosniff
{
"access": {
"token": "a14cec8e4d3f4888a27f31fb0b54ee25"
},
"data": {
"status": "draft",
"assetType": "basic",
"classification": {
"scheme": "CAV",
"description": "Земельні ділянки",
"id": "39513200-3"
},
"title": "Земля для космодрому",
"assetID": "UA-2017-08-16-000002",
"value": {
"currency": "UAH",
"amount": 100.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2017-08-16T18:36:14.032506+03:00",
"owner": "broker",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"address": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"date": "2017-08-16T18:36:14.030468+03:00",
"id": "bb2d3063c01346cb8a7f9f747dbd02b6",
"unit": {
"code": "39513200-3",
"name": "item"
},
"quantity": 5
}
}
Error Response¶
In the event of an error, the response body will contain an errors field at the top level. It contains an array of at least one error object, described below:
location: | Part of the request causing the error. Possible values are header and body. |
---|---|
name: |
|
description: | Verbose (human readable) description of the error. |
Example Error Response¶
Sample below indicates incomplete request.
POST /api/0.1/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 4
Content-Type: application/x-www-form-urlencoded
Host: lb.api-sandbox.registry.ea.openprocurement.net
415 Unsupported Media Type
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"status": "error",
"errors": [
{
"description": "Content-Type header should be one of ['application/json']",
"location": "header",
"name": "Content-Type"
}
]
}