Advertisement
ioggstream

dati_mit_gov_it_yaml

May 3rd, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 23.67 KB | None | 0 0
  1. swagger: '2.0'
  2. info:
  3.   description: |
  4.    Simple API to manage open data sets in data.mit.gov.it
  5.  
  6.     # Important note
  7.     This is not a traditional rest API in the strict sense. **It does not use PUT or DELETE http methods**. Instead, it does everything with GET or POST methods. This means that the color coding in the (swagger) documentation is misleading.
  8.  
  9.     # Open and limited access functions
  10.  
  11.     Functions which can be used **without authorization are grouped under _consumers_**.
  12.     Some API functions **require authorization (grouped under _admins_)**. With these methods you will need API key provided by CKAN system.
  13.  
  14.     **In every API call you need to provide APInf platform specific API-key**. You can get that by creating account. After logging in, your API key is visible in every API profile page (top right corner).
  15.     <center>
  16.     ![Imgur](https://i.imgur.com/bEGmr2s.png)
  17.     </center>
  18.  
  19.     # A few simple examples
  20.  
  21.     **Simple example to list datasets** is:
  22.  
  23.     ``curl -X GET "https://mit.gov.it/catalog/api/3/package_list" -H  "X-API-Key: YOUR APINF API KEY"``
  24.  
  25.     which returns JSON formatted list of datasets.
  26.  
  27.     **Simple example to view details of one dataset** is:
  28.  
  29.     ``curl -X GET "https://mit.gov.it/catalog/api/3/package_show?id=digiroad" -H  "X-API-Key: YOUR APINF API KEY"``
  30.  
  31.     which returns JSON formatted detailed infomation about identified dataset.
  32.  
  33.  
  34.     # Authentication and API keys
  35.  
  36.     There's two kind of keys:
  37.     - **X-API-Key**. APInf Platform API key used in analytics. This required in all API calls. You can get that by creating account. After logging in, your API key is visible in every API profile page (right top corner).
  38.     - **Authorization**. To authorize user to do admin operations in CKAN system. This key can be obtained by signing up to https://beta.avoindata.fi.
  39.  
  40.     Some API functions require authorization (grouped under _admins_). The API uses the same authorization functions and configuration as the web interface, so if a user is authorized to do something in the web interface they’ll be authorized to do it via the API as well.
  41.  
  42.     When calling an API function that requires authorization, you must authenticate yourself by providing your API key with your HTTP request. To find your API key, login to the CKAN site using its web interface and visit your user profile page. In SwaggerUI, you need to input CKAN authorization API-key to _Authorization_ value field. Open authentication dialog by clicking _Authorize_ button.
  43.  
  44.     # Datamodels
  45.  
  46.     All datamodels used are defined in separate service. LINKS HERE!
  47.  
  48.   version: 3
  49.   title: dati.mit.gov.it API
  50.   # put the contact info for your development or API team
  51.   contact:
  52.     email: you@your-company.com
  53.  
  54.   license:
  55.     name: Apache 2.0
  56.     url: http://www.apache.org/licenses/LICENSE-2.0.html
  57. schemes:
  58. - https
  59. securityDefinitions:
  60. #  key:
  61. #    type: apiKey
  62. #    in: header
  63. #    name: X-API-Key
  64.   ckanapikey:
  65.     type: apiKey
  66.     name: Authorization
  67.     in: header
  68.  
  69. # tags are used for organizing operations
  70. tags:
  71. - name: consumers
  72.   description: Operations available to regular consumers
  73. - name: admins
  74.   description: Secured Admin-only calls
  75.  
  76. paths:
  77.   /package_list:
  78.     get:
  79.      ## security:
  80.       ##  - key: []
  81.       tags:
  82.      - consumers
  83.       summary: List all datasets within given limit
  84.       operationId: listInventory
  85.       description: |
  86.        List or search all datasets
  87.       produces:
  88.      - application/json
  89.       parameters:
  90.       - in: query
  91.         name: offset
  92.         description: when limit is given, the offset to start returning packages from
  93.         required: false
  94.         type: integer
  95.       - in: query
  96.         name: limit
  97.         description: if given, the list of datasets will be broken into pages of at most limit datasets per page and only one page will be returned at a time (optional)
  98.         type: integer
  99.         format: int32
  100.       responses:
  101.         200:
  102.           description: search results matching criteria
  103.           schema:
  104.             type: array
  105.             items:
  106.               $ref: '#/definitions/InventoryItem'
  107.         400:
  108.           description: bad input parameter
  109.  
  110.   /package_search:
  111.     get:
  112.      ## security:
  113.       ##  - key: []
  114.       tags:
  115.      - consumers
  116.       summary: Search among all datasets
  117.       operationId: searchInventory
  118.       description: |
  119.        List or search all datasets
  120.       produces:
  121.      - application/json
  122.       parameters:
  123.       - in: query
  124.         name: q
  125.         description: the solr query. For example ``name:pdf-testi``
  126.         required: false
  127.         type: string
  128.         default: "*:*"
  129.       - in: query
  130.         name: fq
  131.         type: string
  132.         description: |
  133.           any filter queries to apply. Note: +site_id:{ckan_site_id} is added to this string prior to the query being executed.
  134.  
  135.       - in: query
  136.         name: sort
  137.         description: |
  138.           sorting of the search results. Optional. **Default: 'relevance asc, metadata_modified desc'**. As per the solr documentation, this is a comma-separated string of field names and sort-orderings.
  139.         required: false
  140.         type: string
  141.         default: "relevance asc, metadata_modified desc"
  142.       - in: query
  143.         name: rows
  144.         description: the number of matching rows to return. There is a hard limit of 1000 datasets per query.
  145.         required: false
  146.         type: integer
  147.       - in: query
  148.         name: start
  149.         type: integer
  150.         description: the offset in the complete result for where the set of returned datasets should begin.
  151.       - in: query
  152.         name: include_drafts
  153.         type: boolean
  154.         default: false
  155.         description: if True, draft datasets will be included in the results. A user will only be returned their own draft datasets, and a sysadmin will be returned all draft datasets. Optional, the default is False.
  156.       responses:
  157.         200:
  158.           description: search results matching criteria
  159.           schema:
  160.             type: array
  161.             items:
  162.               $ref: '#/definitions/InventoryItem'
  163.         400:
  164.           description: bad input parameter
  165.         409:
  166.           description: Conflict (can result e.g. from incorrectly formatted solr query)
  167.  
  168.  
  169.   /package_show:
  170.     get:
  171.      ##security:
  172.       ##  - key: []
  173.       tags:
  174.      - consumers
  175.       summary: Get details of one package
  176.       operationId: showInventory
  177.       description: |
  178.        List or search all datasets
  179.       produces:
  180.      - application/json
  181.       parameters:
  182.       - in: query
  183.         name: id
  184.         description: the id or name of the dataset
  185.         required: true
  186.         type: string
  187.       - in: query
  188.         name: include_tracking
  189.         description: |
  190.           add tracking information to dataset and resources (default: False)
  191.         type: boolean
  192.         default: false
  193.       responses:
  194.         200:
  195.           description: search results matching criteria
  196.           schema:
  197.             type: array
  198.             items:
  199.               $ref: '#/definitions/InventoryItem'
  200.         400:
  201.           description: bad input parameter
  202.  
  203.   /organization_list:
  204.     get:
  205.      ##security:
  206.       ##  - key: []
  207.       tags:
  208.      - consumers
  209.       summary: List all groups within given parameters
  210.       operationId: listOrgs
  211.       description: |
  212.        List or search all datasets
  213.       produces:
  214.      - application/json
  215.       parameters:
  216.       - in: query
  217.         name: sort
  218.         description: |
  219.           sorting of the search results. Optional. Default: “name asc” string of field name and sort-order. The allowed fields are ‘name’, ‘package_count’ and ‘title’
  220.         required: false
  221.         default: "name asc"
  222.         type: string
  223.       - in: query
  224.         name: limit
  225.         description: |
  226.          if given, the list of organizations will be broken into pages of at most limit organizations per page and only one page will be returned at a time (optional)
  227.         type: integer
  228.         format: int32
  229.       - in: query
  230.         name: offset
  231.         description: |
  232.          when limit is given, the offset to start returning organizations from
  233.         type: integer
  234.         format: int32
  235.         required: false
  236.       - in: query
  237.         name: organizations
  238.         type: string
  239.         description: |
  240.          a list of names of the groups to return, if given only groups whose names are in this list will be returned (optional)
  241.         required: false
  242.       - in: query
  243.         type: boolean
  244.         name: all_fields
  245.         description: |
  246.           return group dictionaries instead of just names. Only core fields are returned - get some more using the include_* options. Returning a list of packages is too expensive, so the packages property for each group is deprecated, but there is a count of the packages in the package_count property. (optional, default: False)
  247.         required: false
  248.       - in: query
  249.         name: include_dataset_count
  250.         type: boolean
  251.         default: true
  252.         description: |
  253.           if all_fields, include the full package_count (optional, default: True)
  254.       - in: query
  255.         name: include_extras
  256.         type: boolean
  257.         description: |
  258.           if all_fields, include the organization extra fields (optional, default: False)
  259.         default: false
  260.       - in: query
  261.         name: include_tags
  262.         type: boolean
  263.         description: |
  264.           if all_fields, include the organization tags (optional, default: False)
  265.         default: false
  266.       - in: query
  267.         name: include_groups
  268.         type: boolean
  269.         description: |
  270.           if all_fields, include the organizations the organizations are in (optional, default: False)
  271.         default: false
  272.       - in: query
  273.         name: include_users
  274.         type: boolean
  275.         description: |
  276.           if all_fields, include the organization users (optional, default: False).
  277.         default: false
  278.       responses:
  279.         200:
  280.           description: search results matching criteria
  281.           schema:
  282.             type: array
  283.             items:
  284.               $ref: '#/definitions/InventoryItem'
  285.         400:
  286.           description: bad input parameter
  287.  
  288.   /package_create:
  289.     post:
  290.       security:
  291.         - ckanapikey: []
  292.       tags:
  293.      - admins
  294.       summary: Create a new dataset (package)
  295.       operationId: addDataset
  296.       description: Creates a new dataset (package) to the system. You must be authorized to create new datasets. If you specify any groups for the new dataset, you must also be authorized to edit these groups.
  297.       consumes:
  298.      - application/json
  299.       produces:
  300.      - application/json
  301.       parameters:
  302.       - in: body
  303.         name: inventoryItem
  304.         description: Inventory item to add
  305.         schema:
  306.           $ref: '#/definitions/dataset_package_create'
  307.       responses:
  308.         201:
  309.           description: item created
  310.         400:
  311.           description: invalid input, object invalid
  312.         409:
  313.           description: an existing item already exists
  314.   /package_update:
  315.     post:
  316.       security:
  317.         - ckanapikey: []
  318.       tags:
  319.      - admins
  320.       summary: Update a dataset (package).
  321.       operationId: updateDataset
  322.       description: Update a dataset (package). You must be authorized to edit the dataset and the groups that it belongs to.
  323.       consumes:
  324.      - application/json
  325.       produces:
  326.      - application/json
  327.       parameters:
  328.       - in: body
  329.         name: inventoryItem
  330.         description: Inventory item to add
  331.         schema:
  332.           $ref: '#/definitions/dataset_package_update'
  333.       responses:
  334.         200:
  335.           description: OK, dataset updated.
  336.         400:
  337.           description: Invalid input, object invalid.
  338.         404:
  339.           description: Object not found for update.
  340.   /package_delete:
  341.     post:
  342.       security:
  343.         - ckanapikey: []
  344.       tags:
  345.      - admins
  346.       summary: Delete a dataset (package)
  347.       operationId: deleteDataset
  348.       description: This makes the dataset disappear from all web & API views, apart from the trash.
  349.       consumes:
  350.      - application/json
  351.       produces:
  352.      - application/json
  353.       parameters:
  354.       - in: body
  355.         name: id
  356.         description: id (string) – the id or name of the dataset to delete.
  357.         schema:
  358.           $ref: '#/definitions/delete'
  359.       responses:
  360.         200:
  361.           description: OK, dataset deleted.
  362.         404:
  363.           description: =bject not found for deletion.
  364.   /organization_create:
  365.     post:
  366.       security:
  367.         - ckanapikey: []
  368.       tags:
  369.      - admins
  370.       summary: Create a new organization.
  371.       operationId: addOrg
  372.       description: Create a new organization. You must be authorized to create organizations.
  373.       consumes:
  374.      - application/json
  375.       produces:
  376.      - application/json
  377.       parameters:
  378.       - in: body
  379.         name: inventoryItem
  380.         description: Inventory item to add
  381.         schema:
  382.           $ref: '#/definitions/dataset_organization_create'
  383.       responses:
  384.         201:
  385.           description: Organization created
  386.         400:
  387.           description: Invalid input, object invalid
  388.         409:
  389.           description: An existing item already exists
  390.   /organization_update:
  391.     post:
  392.       security:
  393.         - ckanapikey: []
  394.       tags:
  395.      - admins
  396.       summary: Update a organization.
  397.       operationId: updateOrg
  398.       description: Update a organization. You must be authorized to edit the organization.
  399.       consumes:
  400.      - application/json
  401.       produces:
  402.      - application/json
  403.       parameters:
  404.       - in: body
  405.         name: inventoryItem
  406.         description: Inventory item to add
  407.         schema:
  408.           $ref: '#/definitions/dataset_organization_update'
  409.       responses:
  410.         200:
  411.           description: OK, updated.
  412.         400:
  413.           description: Invalid input, object invalid
  414.         404:
  415.           description: Organization not found for update.
  416.   /organization_delete:
  417.     post:
  418.       security:
  419.         - ckanapikey: []
  420.       tags:
  421.      - admins
  422.       summary: Delete an organization.
  423.       operationId: deleteOrg
  424.       description: Delete an organization. You must be authorized to delete the organization.
  425.       consumes:
  426.      - application/json
  427.       produces:
  428.      - application/json
  429.       parameters:
  430.       - in: body
  431.         name: id
  432.         description: id (string) – the id or name of the organization to delete
  433.         schema:
  434.           $ref: '#/definitions/delete'
  435.       responses:
  436.         200:
  437.           description: OK, organization deleted.
  438.         400:
  439.           description: Invalid input, object invalid.
  440.         404:
  441.           description: Organization not found for deletion.
  442.  
  443.   /user_list:
  444.     get:
  445.       security:
  446.         - ckanapikey: []
  447.       tags:
  448.      - admins
  449.       summary: List users
  450.       operationId: listUsers
  451.       description: Return a list of the site’s user accounts.
  452.       consumes:
  453.      - application/json
  454.       produces:
  455.      - application/json
  456.       parameters:
  457.       - in: query
  458.         name: q
  459.         required: false
  460.         default: "*"
  461.         description: Restrict the users returned to those whose names contain a string. Optional.
  462.         type: string
  463.       - in: query
  464.         name: order_by
  465.         required: false
  466.         default: "*"
  467.         description: Which field to sort the list by. Can be any user field or edits (i.e. number_of_edits). Optional.
  468.         type: string
  469.       - in: query
  470.         name: all_fields
  471.         required: false
  472.         default: True
  473.         description: Return full user dictionaries instead of just names.  Optional.
  474.         type: boolean
  475.  
  476.       responses:
  477.         200:
  478.           description: Returns a list of users. if there is no match, empty list is returned.
  479.           examples:
  480.             application/json:
  481.              {
  482.                 "help": "https://beta.avoindata.fi/data/api/3/action/help_show?name=user_list",
  483.                 "success": true,
  484.                 "result": [
  485.                   {
  486.                     "openid": null,
  487.                     "about": null,
  488.                     "apikey": "916f7088-5828-4e25-a0da-f5fcad281af2",
  489.                     "display_name": "makkonenmakkonen",
  490.                     "name": "etunimi sukunimi",
  491.                     "created": "2017-10-31T15:05:59.402582",
  492.                     "email": "esa.merkki@apinf.io",
  493.                     "sysadmin": false,
  494.                     "activity_streams_email_notifications": false,
  495.                     "state": "active",
  496.                     "number_of_edits": 3,
  497.                     "fullname": null,
  498.                     "id": "9d886b53-2f4a-4ed8-8482-bd2cb9d0d5fe",
  499.                     "number_created_packages": 3
  500.                   }
  501.                 ]
  502.               }
  503.  
  504.         400:
  505.           description: invalid input, object invalid.
  506.         403:
  507.           description: Forbidden, authorization key missing.
  508.         409:
  509.           description: Item already exists.
  510.  
  511.  
  512. definitions:
  513.   delete:
  514.     type: object
  515.  
  516.     properties:
  517.       id:
  518.         type: string
  519.         example: id-to-delete
  520.         description: |
  521.          Id to delete
  522.  
  523.   dataset_package_create:
  524.     type: object
  525.     required:
  526.      - name
  527.       - collection_type
  528.       - license_id
  529.       - owner_org
  530.       - keywords
  531.       - title_translated
  532.       - notes_translated
  533.       - maintainer
  534.       - maintainer_email
  535.  
  536.     properties:
  537.       name:
  538.         type: string
  539.         description: |
  540.          the name of the new dataset, must be between 2 and 100 characters long and contain only lowercase alphanumeric characters, - and _, e.g. 'warandpeace'
  541.         example: name
  542.       collection_type:
  543.         type: string
  544.         default: "Open Data"
  545.         description: |
  546.          'Open Data' or 'Interoperability Tools' values allowed
  547.         example: Open Data
  548.       license_id:
  549.         type: string
  550.         example: EUPL
  551.         description: |
  552.          License
  553.       owner_org:
  554.         type: string
  555.         description: |
  556.          Owner; 'yksityishenkilo' value allowed at the moment
  557.         example: yksityishenkilo
  558.       keywords:
  559.         type: object
  560.         description: |
  561.          Localised keywords
  562.         example:
  563.           fi: ["eka","toka","kolmas"]
  564.       title_translated:
  565.         type: object
  566.         description: |
  567.          list of localised titles
  568.         example:
  569.           fi: Aihe suomeksi
  570.           de: Thema in Deutsche
  571.       notes_translated:
  572.         type: object
  573.         description: |
  574.          list of localised notes
  575.         example:
  576.           fi: Muistiinpanot suomeksi
  577.           de: Notiz in Deutsche
  578.       maintainer:
  579.         type: string
  580.         description: |
  581.          Maintainer of this data
  582.         example: Jarkko Pöntiö
  583.       maintainer_email:
  584.         type: string
  585.         description: |
  586.          Maintainer email
  587.         example: jarkko.pontio@somedomainhere.com
  588.  
  589.   dataset_package_update:
  590.     type: object
  591.     required:
  592.      - id
  593.       - name
  594.       - license_id
  595.       - collection_type
  596.       - owner_org
  597.     properties:
  598.       id:
  599.         type: string
  600.         example: example id
  601.         description: |
  602.           the name or id of the dataset to update
  603.       name:
  604.         type: string
  605.         example: organization
  606.         description: name of the package to update
  607.       license_id:
  608.         type: string
  609.         description: id of the licence
  610.         example: ididididid
  611.       collection_type:
  612.         type: string
  613.         default: "Open Data"
  614.         description: |
  615.          'Open Data' or 'Interoperability Tools' values allowed
  616.         example: Open Data
  617.       owner_org:
  618.         type: string
  619.         description: |
  620.          Owner; 'yksityishenkilo' value allowed at the moment
  621.         example: yksityishenkilo
  622.  
  623.   dataset_organization_create:
  624.     type: object
  625.     required:
  626.      - name
  627.  
  628.     properties:
  629.       name:
  630.         type: string
  631.         example: "nameofanorganization"
  632.         description: |
  633.          Name (string) – the name of the organization, a string between 2 and 100 characters long, containing only lowercase alphanumeric characters, - and _
  634.       id:
  635.         type: string
  636.         example: ididididid
  637.         description: |
  638.          ID of the organization (optional)
  639.       title:
  640.         type: string
  641.         example: title
  642.         description: |
  643.          the title of the organization (optional)
  644.  
  645.       description:
  646.         type: string
  647.         example: great organization
  648.         description: |
  649.          Description of the organization
  650.  
  651.       image_url:
  652.         type: string
  653.         example: http://image.url.com/exxaample.gif
  654.         description: |
  655.          the URL to an image to be displayed on the organization’s page (optional)
  656.  
  657.       state:
  658.         type: string
  659.         example: active
  660.         description: |
  661.           the current state of the organization, e.g. 'active' or 'deleted', only active organizations show up in search results and other lists of organizations, this parameter will be ignored if you are not authorized to change the state of the organization (optional, default: 'active')
  662.  
  663.       approval_status:
  664.         type: string
  665.         example: status description
  666.         description: |
  667.          (string) – (optional)
  668.  
  669.       extras:
  670.         type: object
  671.         example: [{"value": ["value1"], "key": ["key1"], "active":["false"]}]
  672.         description: |
  673.           (list of dataset extra dictionaries) – the organization’s extras (optional), extras are arbitrary (key: value) metadata items that can be added to organizations, each extra dictionary should have keys 'key' (a string), 'value' (a string), and optionally 'deleted'
  674.  
  675.       packages:
  676.         type: object
  677.         example: [{"id": "8de6e388-20c1-dddd-df3d-c445f447f1cg", "title":"title"}]
  678.         description: |
  679.          (list of dictionaries) – the datasets (packages) that belong to the organization, a list of dictionaries each with keys 'name' (string, the id or name of the dataset) and optionally 'title' (string, the title of the dataset)
  680.  
  681.       users:
  682.         type: object
  683.         example: [{"name":"mikko", "capacity": "capacity manager"}, {"name": "suusanna"}]
  684.         description: |
  685.          (list of dictionaries) – the datasets (packages) that belong to the organization, a list of dictionaries each with keys 'name' (string, the id or name of the dataset) and optionally 'title' (string, the title of the dataset)
  686.  
  687.   dataset_organization_update:
  688.     type: object
  689.     required:
  690.      - id
  691.  
  692.     properties:
  693.       name:
  694.         type: string
  695.         example: "nameofanorganization"
  696.         description: |
  697.          Name (string) – the name of the organization, a string between 2 and 100 characters long, containing only lowercase alphanumeric characters, - and _
  698.       id:
  699.         type: string
  700.         example: ididididid
  701.         description: |
  702.          ID of the organization
  703.  
  704.   InventoryItem:
  705.     type: object
  706.     required:
  707.    - id
  708.     - name
  709.     - manufacturer
  710.     - releaseDate
  711.     properties:
  712.       id:
  713.         type: string
  714.         format: uuid
  715.         example: d290f1ee-6c54-4b01-90e6-d701748f0851
  716.       name:
  717.         type: string
  718.         example: Widget Adapter
  719.       releaseDate:
  720.         type: string
  721.         format: int32
  722.         example: 2016-08-29T09:12:33.001Z
  723.       manufacturer:
  724.         $ref: '#/definitions/Manufacturer'
  725.   Manufacturer:
  726.     required:
  727.    - name
  728.     properties:
  729.       name:
  730.         type: string
  731.         example: ACME Corporation
  732.       homePage:
  733.         type: string
  734.         format: url
  735.         example: https://www.acme-corp.com
  736.       phone:
  737.         type: string
  738.         example: 408-867-5309
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement