API

Providing version 1 ( v1 ) API for gStudio, built with native python methods and mongo queries. In next version 2 ( v2 ), we will be having comprehensive API’s built on top of Elastic-Search.

Glossary: 1. Workspace: - Workspace is where all nodes get published. Every node must have one or more workspace IDs in their property named ‘group_set’. The default workspace of gStudio is ‘home’.

  1. Resource Type:
    • Resource type are different types of resources (published as Nodes) which exist in gStudio. Most common default Resource Types are ‘Page’, ‘File’, ‘Event’, ‘Course’ etc. Every node published in gStudio will have reference to Workspace and Resource Type. That is how we know how a node is typed (object of which type) and where (in which workspace) it is published.
  2. Resource:
    • Resource is actual nodes of the respository. Each resource is described with fields specified below. Resources are published under atleast one workspace and are a member of a Resource Type. Common examples of Resource Types are: Page or File. The reference to Resource Type can be read from the field `member_of.

Resource Fields - “_id”: a UUID (Primary Key) auto generated by mongoDB. - “name”: Name of resource. Short concise, Mostly unique. Uniqueness is maintained only for each Workspace, and for each Resource Type. - “altnames”: Display Name. It can be elaborative, long. It is recommended that UI will use this value when present. - “language”*: Language code in ISO 639-2 standard. (e.g: [“hi”, “Hindi”]) - “content”: Description/content of resource. - “if_file”: Contains information of media urls in nested dictionary. Following is schema of if_file:

    {
        'mime_type': ,
        'original': {'id': , 'relurl': },
        'mid': {'id': , 'relurl': },
        'thumbnail': {'id': , 'relurl': }
    }
    
- mime_type: Indicates MIME type of resource, mostly filled if the resource is a file.
- original: URL of original/uploaded file resource.
- mid: URL of mid/converted form of original file. This can be mid-size image for images and `.webm` for videos. Blank for other resource types.
- thumbnail: Thumbnail of uploaded resource (mostly it's available for images and videos).
- *NOTE: URL's are relative urls of site. Prepend relative value with `<domain>/media/`*

- e.g:
    <PRE>
    {
        "mime_type": "video/mp4",
        "original": {
                "id": "59a90dd2738242080c921465",
                "relurl": "1/3/4/25a8cbe5c27367145b1ae8bf5bebb7979679d9d3e5609e6ed48170def44c6.mp4"
            },
        "mid": {
                "id": "59a91e7d73824201c2066320",
                "relurl": "c/1/9/8bbbad19debc7857a091cf1164c60726e8713e12d1199352d721dc4d91805.webm"
            },
        "thumbnail": {
                "id": "59a91e7c73824201c206631f",
                "relurl": "6/8/5/d331ff73b657ccd2326354aff03be08d692b0a26ba92ef22295144a49abdc.png"
            }
    }
    <PRE>
  • “tags”: Tokens of concerned informative identifiers to describe resource, similar to keywords.
  • “location”: List of GeoJson format JSON.
  • “legal”: Dictionary of “copyright” and “License”.
  • “rating”: List/Array of multiple ratings given. [{‘score’: , ‘user_id’: , ‘ip_address’: }]
  • “access_policy”: Policy for resource visibilty. It can have either Public or Private value.
  • “status”: Indicates current status of resource. It can have either of: “DRAFT”, “HIDDEN”, “PUBLISHED”, “DELETED”, “MODERATION”.
  • “member_of”: [resource_type] Indicates which type of Node it is. E.g: “File”, “Page” etc.
  • “type_of”: Specialization of resource type. Used only for Resource Type nodes. Usually blank.
  • “group_set”: [workspace] Denotes list of group/workspace names under which this resource is published.
  • “created_by”: Name of creator.
  • “modified_by”: Name of modifier/editor.
  • “contributors”: List of all users, contributed this resource.
  • “created_at”: Datetime stamp in DD/MM/YYYY HH:MM:SS format. E.g: 01/09/2017 13:07:07
  • “last_update”: Datetime stamp in DD/MM/YYYY HH:MM:SS format. E.g: 01/09/2017 13:07:07
  • “collection_set”: List of resource names to organize resources.
  • “post_node”: N/A
  • “prior_node”: List of pre-requisites of concern resource.
  • “relation_set”: Objects relations in a key value pair form. Value can be single ObjectId or list of ObjectId.
  • curricular: Boolean value either true or false. Specifies resource is curricular or not.
  • educationalalignment: E.g: NCF
  • educationalsubject: Subjects.
  • educationallevel: Five levels primary to tertiary. E.g: Upper Primary, Secondary, Senior Secondary
  • audience: E.g: Teachers, Students
  • educationaluse: 1) Images 2) Audios 3) Videos 4) Interactives 5) Documents 6) Maps 7) Events 8) Publications
  • interactivitytype: E.g: Active, Expositive, Mixed etc.
  • source: Source of the resource. Example website or organization name. E.g: CIET, NCERT, Vigyan Prasar
  • basedonurl: URL of site from where it has been referenced/based on. If translated work or a creation based on an existing resource.
  • timerequired: Time required to read/view resource.
  • textcomplexity: Complexity
  • readinglevel: e.g: Easy, Moderate or Difficult
  • age_range: Approximate age range of viewer.
  • adaptation_of: Link to the resource

Example API calls: Examples can be used on live nroer.gov.in server.

List possible query keys: - http://nroer.gov.in/api/v1

List possible values for query keys - http://nroer.gov.in/api/v1/tags - http://nroer.gov.in/api/v1/status

List json objects with various key and value combination: - http://nroer.gov.in/api/v1?tags=creative - http://nroer.gov.in/api/v1?resource_type=File&tags=creative - http://nroer.gov.in/api/v1?workspace=home&resource_type=File&tag=creative - http://nroer.gov.in/api/v1/?workspace=home&resource_type=File&created_by=nroer_team&educationaluse=Images - http://nroer.gov.in/api/v1/?workspace=home&resource_type=File&educationalsubject=history - http://nroer.gov.in/api/v1/?workspace=home&resource_type=File&source=CIET,%20NCERT - http://nroer.gov.in/api/v1/?workspace=home&resource_type=File&created_by=nroer_team&legal.copyright=CC-BY-SA%204.0%20unported&interactivitytype=expositive&educationaluse=image

Relation support: - Check for field relation_set in every object. It contains dict of relation-name (key) and ObjectId or [ObjectId] as value. - We can derive full object with //<domain>/api/v1?_id=<ObjectId> API call. - Example: To list out the topic (“Patterns and Symmetry”): https://nroer.gov.in/api/v1?resource_type=Topic&name=Patterns%20and%20Symmetry - To get detail about one object of taught_by: https://nroer.gov.in/api/v1?_id=5af1810816b51c01e3736a5c - NOTE: Get additional/complete details of object: https://nroer.gov.in/dev/query/5af1810816b51c01e3736a5c/nbh

If you need more specific help, contact the developers on the mailing list, or file an issue at the git repo.