get - NGSI command

This command gets an entity, an attribute, multiple attributes, a subscription or a registration.

Common Options

Options Description
--host value, -h value specify host or alias
--token value specify oauth token
--service value, -s value specify FIWARE Service
--path value, -p value specify FIWARE ServicePath
--help show help (default: false)

Get an entity

This command gets entity.

ngsi get [command options] entity [options]

Options

Options Description
--id value, -i value specify id
--type value, -t value specify entity type
--attrs value specify attributes
--keyValues, -k specify keyValues (default: false)
--values, -V specify values (default: false)
--unique, -u specify unique (default: false)
--sysAttrs, -s specify sysAttrs (default: false)
--link value, -L value specify @context
--acceptJson set accecpt header to application/json (LD) (default: false)
--acceptGeoJson set accecpt header to application/geo+json (LD) (default: false)
--acceptJson set accecpt header to application/json (LD)
--pretty, -P pretty format (default: false)
--safeString value use safe string (value: on/off)
--help show help (default: false)

Examples

Request:

ngsi get entity --id urn:ngsi-ld:Product:010 --type Product
{"id":"urn:ngsi-ld:Product:010","type":"Product","name":{"type":"Text","value":"Lemonade","metadata":{}},"price":{"type":"Integer","value":99,"metadata":{}},"size":{"type":"Text","value":"S","metadata":{}}}

Request:

ngsi get entity --id urn:ngsi-ld:Product:010 --type Product --keyValues
{"id":"urn:ngsi-ld:Product:010","type":"Product","name":"Lemonade","price":99,"size":"S"}

Request:

ngsi get entity --id urn:ngsi-ld:Product:010 --type Product --keyValues --attrs size
{"id":"urn:ngsi-ld:Product:010","type":"Product","size":"S"}

Get multiple entities

This command gets multiple entities.

ngsi get [command options] entities [options]

Options

Options Description
--orderBy value specify orderBy
--count, -C specify count (default: false)
--keyValues, -k specify keyValues (default: false)
--values, -V specify values (default: false)
--unique, -u specify unique (default: false)
--verbose, -v specfiy verbose (default: false)
--lines, -1 specify lines (default: false)
--data value, -d value specify data
--pretty, -P pretty format (default: false)
--safeString value use safe string (value: on/off)
--help show help (default: false)

Examples

Request:

ngsi get entities --data '{"entities": [{"type": "Device", "idPattern": ".*"}],"attrs":["name"]}'

Get temporal entity

This command gets a temporal entity.

ngsi get [common options] tentity [options]

Options

Options Description
--id value, -i value id
--attrs value attributes
--timeProperty value timeProperty (LD)
--fromDate value starting date from which data should be retrieved
--toDate value final date until which data should be retrieved
--lastN value number of data entries to retrieve since the final date backwards (default: 0)
--link value, -L value @context (LD)
--temporalValues temporal simplified representation of entity (default: false)
--sysAttrs, -S sysAttrs (default: false)
--acceptJson set accecpt header to application/json (LD) (default: false)
--pretty, -P pretty format (default: false)
--safeString value use safe string (value: on/off)
--etsi10 ETSI CIM 009 V1.0 (default: false)
--help show help (default: false)

Get an attribute

This command gets an attribute value.

ngsi get [common options] attr [options]

Options

Options Description
--id value, -i value specify id
--type value, -t value specify entity type
--attr value specify attribute name
--pretty, -P pretty format (default: false)
--safeString value use safe string (value: on/off)
--help show help (default: false)

Examples

Request:

ngsi get attr --id urn:ngsi-ld:Product:010 --type Product --attr size "S"

Get multiple attributes

This command gets attributes.

ngsi get [common options] attrs [options]

Options

Options Description
--id value, -i value specify id
--type value, -t value specify Entity Type
--attrs value specify attrs
--metadata value specify metadata
--keyValues, -k specify keyValues (default: false)
--values, -V specify values (default: false)
--unique, -u specify unique (default: false)
--pretty, -P pretty format (default: false)
--safeString value use safe string (value: on/off)
--help show help (default: false)

Examples

Request:

ngsi get attrs --type Product --id urn:ngsi-ld:Product:001 --attrs name,price
{"name":{"type":"Text","value":"Beer","metadata":{}},"price":{"type":"Integer","value":99,"metadata":{}}}

Request:

ngsi get attrs --type Product --id urn:ngsi-ld:Product:001 --attrs name,price --keyValues
{"name":"Beer","price":99}

Request:

ngsi get attrs --type Product --id urn:ngsi-ld:Product:001 --attrs name,price --values
["Beer",99]

Get a subscription

This command gets a subscription.

ngsi get [common options] subscription [options]

Options

Options Description
--id value, -i value specify id
--localTime localTime (default: false)
--pretty, -P pretty format (default: false)
--safeString value use safe string (value: on/off)
--help show help (default: false)

Examples for NGSIv2

Request:

ngsi get subscription --id 5fa7988a627088ba9b91b1c1 --pretty
{
  "id": "5fa7988a627088ba9b91b1c1",
  "subject": {
    "entities": [
      {
        "idPattern": ".*",
        "type": "Sensor"
      }
    ],
    "condition": {
      "attrs": [
        "temperature"
      ]
    }
  },
  "notification": {
    "onlyChangedAttrs": false,
    "http": {
      "url": "http://192.168.0.1/"
    },
    "attrs": [
      "notification"
    ],
    "attrsFormat": "normalized"
  },
  "expires": "2020-11-09T07:04:42.000Z",
  "status": "active"
}

Request:

ngsi get subscription --id 5fa7988a627088ba9b91b1c1 --localTime --pretty
{
  "id": "5fa7988a627088ba9b91b1c1",
  "subject": {
    "entities": [
      {
        "idPattern": ".*",
        "type": "Sensor"
      }
    ],
    "condition": {
      "attrs": [
        "temperature"
      ]
    }
  },
  "notification": {
    "onlyChangedAttrs": false,
    "http": {
      "url": "http://192.168.0.1/"
    },
    "attrs": [
      "notification"
    ],
    "attrsFormat": "normalized"
  },
  "expires": "2020-11-09T16:04:42.000+0900",
  "status": "active"
}

Examples for NGSI-LD

Request:

ngsi get subscription --id urn:ngsi-ld:Subscription:5f67fd65ef40bb66fe006dce --pretty
{
  "id": "urn:ngsi-ld:Subscription:5f67fd65ef40bb66fe006dce",
  "type": "Subscription",
  "description": "Notify me of low stock in Store 001",
  "entities": [
    {
      "type": "Shelf"
    }
  ],
  "watchedAttributes": [
    "numberOfItems"
  ],
  "q": "https://fiware.github.io/tutorials.Step-by-Step/schema/numberOfItems<10;https://fiware.github.io/tutorials.Step-by-Step/schema/locatedIn==urn:ngsi-ld:Building:store001",
  "notification": {
    "attributes": [
      "numberOfItems",
      "stocks",
      "locatedIn"
    ],
    "format": "keyValues",
    "endpoint": {
      "uri": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld",
      "accept": "application/ld+json"
    }
  }
}

Get a registration

This command gets a registration.

ngsi get [common options] registration [options]

Options

Options Description
--id value, -i value specify id
--localTime specify localTime (default: false)
--pretty, -P pretty format (default: false)
--safeString value use safe string (value: on/off)
--help show help (default: false)

Examples for NGSI-LD

Request:

ngsi get registration --id urn:ngsi-ld:ContextSourceRegistration:5f6840e6ef40bb66fe006dd0 --pretty
{
  "id": "urn:ngsi-ld:ContextSourceRegistration:5f6840e6ef40bb66fe006dd0",
  "type": "ContextSourceRegistration",
  "description": "ContextSourceRegistration",
  "endpoint": "http://context-provider:3000/static/tweets",
  "information": [
    {
      "entities": [
        {
          "id": "urn:ngsi-ld:Building:store001",
          "type": "Building"
        }
      ],
      "properties": [
        "tweets"
      ]
    }
  ]
}