Flexible NoSQL hotness. With search.

4.3 Item API

  • http://api.thriftdb.com/{bucket}/{collection}/{item_id}
    Description:
    Create/Read/Update/Delete an item
    HTTP Methods:
    • PUT - Create a new item or update an existing one
      HTTP Responses:
      • 201 Created - Item has been created
      • 200 OK - An existing item has been updated
      Sample Request/Response:
      PUT /test_bucket/cars/1 HTTP/1.1
      HOST: api.thriftdb.com
      
      {
          "make" : "Porsche",
          "model": "911",
          "year" : 1974,
          "color": "red"
      }
      
      HTTP/1.1 201 Created
      Content-Type: application/json
      
      {
          "__class__": "SuccessfulResponse",
          "message"  : "Item has been created: 'test_bucket' >> 'cars' >> '1'"
      }
      
    • GET - Return an existing item
      URL Arguments:
      • Argument Datatype Default
        highlight[q] string none
        highlight[markup_item] boolean false
        highlight[include_matches] boolean false

      • highlight[q]
        The query string to highlight
      • highlight[markup_item]
        If specified, wrap matched terms with <strong> tags
      • highlight[include_matches]
        If specified, include match tokens
      HTTP Responses:
      • 200 OK - Item has been retrieved
      • 404 Not Found - Item does not exist
      Sample Request/Responses:
      GET /test_bucket/cars/1 HTTP/1.1
      HOST: api.thriftdb.com
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      {
          "_id"  : "1",
          "make" : "Porsche",
          "model": "911",
          "year" : 1974,
          "color": "red"
      }
      
      GET /test_bucket/cars/1?highlight[q]=red&highlight[markup_item]=true HTTP/1.1
      HOST: api.thriftdb.com
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      {
          "_id"  : "1",
          "make" : "Porsche",
          "model": "911",
          "year" : 1974,
          "color": "<strong>red</strong>"
      }
      
    • DELETE
      HTTP Responses:
      • 200 OK - Item has been deleted
      • 404 Not Found - Item does not exist
      Sample Request/Response:
      DELETE /test_bucket/cars/1 HTTP/1.1
      HOST: api.thriftdb.com
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      {
          "__class__": "SuccessfulResponse",
          "message"  : "Item has been deleted: 'test_bucket' >> 'cars' >> '1'"
      }
      

  • http://api.thriftdb.com/{bucket}/{collection}/_bulk/put_multi
    Description:
    Create/Update multiple items
    HTTP Methods:
    • POST - Create/update items in bulk
      HTTP Responses:
      • 200 OK - Items have been created or updated
      • 404 Not Found - Bucket or collection does not exist
      Sample Request/Response:
      POST /test_bucket/cars/_bulk/put_multi HTTP/1.1
      HOST: api.thriftdb.com
      
      [
          {"_id"  : "1",
           "make" : "Porsche",
           "model": "911",
           "year" : 1974,
           "color": "black"
           },
          {"_id"  : "2",
           "make" : "Porsche",
           "model": "911",
           "year" : 2007,
           "color": "red"
           },
          {"_id"  : "3",
           "make" : "Dodge",
           "model": "Dynasty",
           "year" : 1984,
           "color": "brown"
           },
          {"_id"  : "4",
           "make" : "Peugeot",
           "model": "206",
           "year" : 2003,
           "color": "red"
           }
      ]
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      {
          "__class__": "SuccessfulResponse",
          "message"  : "Items have been updated/created: [
                          ('test_bucket' >> 'cars' >> '1'),
                          ('test_bucket' >> 'cars' >> '2'),
                          ('test_bucket' >> 'cars' >> '3'),
                          ('test_bucket' >> 'cars' >> '4')]"
      }
      

  • http://api.thriftdb.com/{bucket}/{collection}/_bulk/get_multi
    Description:
    Fetch items in bulk
    HTTP Methods:
    • GET - Fetch multiple items
      URL Arguments:
      • Argument Datatype Default
        ids string none
        highlight[q] string none
        highlight[markup_items] boolean false
        highlight[include_matches] boolean false

      • ids - List of item ids
        • example: http://api.thriftdb.com/test_bucket/cars/_bulk/get_multi?ids=1,2,3
      • highlight[q]
        The query string to highlight
      • highlight[markup_items]
        If specified, wrap matched terms in items with <strong> tags
      • highlight[include_matches]
        If specified, include match tokens
      HTTP Responses:
      • 200 OK - Items have been retrieved
      • 404 Not Found - Bucket or collection does not exist
      Sample Request/Response:
      GET /test_bucket/cars/_bulk/get_multi?ids=1,2,3 HTTP/1.1
      HOST: api.thriftdb.com
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      [
         {"_id"   : "1",
           "make" : "Porsche",
           "model": "911",
           "year" : 1974,
           "color": "black"
           },
          {"_id"  : "2",
           "make" : "Porsche",
           "model": "911",
           "year" : 2007,
           "color": "red"
           },
          {"_id"  : "3",
           "make" : "Dodge",
           "model": "Dynasty",
           "year" : 1984,
           "color": "brown"
           }
      ]
      

  • http://api.thriftdb.com/{bucket}/{collection}/_bulk/delete_multi
    Description:
    Delete items in bulk
    HTTP Methods:
    • POST - Delete multiple items
      URL Arguments:
      • ids - List of item ids
        • example: http://api.thriftdb.com/test_bucket/cars/_bulk/delete_multi?ids=1,2,3
      HTTP Responses:
      • 200 OK - Items have been deleted
      • 404 Not Found - Bucket or collection does not exist
      Sample Request/Response:
      POST /test_bucket/cars/_bulk/delete_multi?ids=1,2,3 HTTP/1.1
      HOST: api.thriftdb.com
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      {
          "__class__": "SuccessfulResponse",
          "message"  : "Items have been deleted: [
                          ('test_bucket' >> 'cars' >> '1'),
                          ('test_bucket' >> 'cars' >> '2'),
                          ('test_bucket' >> 'cars' >> '3')]"
      }
      

  • http://api.thriftdb.com/{bucket}/{collection}/_bulk/reindex
    Description:
    Reindex all data items
    HTTP Methods:
    • POST - Reindex all items in a collection
      HTTP Responses
      • 200 OK - Collection has been reindexed
      • 404 Not Found - Bucket or collection does not exist
      Sample Request/Response:
      POST /test_bucket/cars/_bulk/reindex HTTP/1.1
      HOST: api.thriftdb.com
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      {
          "__class__": "SuccessfulResponse",
          "message"  : "Items in collection have been reindexed: 'test_bucket' >> 'cars'"
      }
      

« Prev Next »