Skip to Main Content
 

Blog title

Now you can do GET/POST/PUT/DELETE operations on all datasets!

INFO_LIST

  • Author Head Binubuo
  • Category Binubuo API
  • Created Tue, Dec 13 2022
 

blog sections

One thing that you have not seen before, is that all dataset services automatically supports almost all of the operations in REST (GET/POST/PUT/DELETE). So not only can you get a full set of rows from the service, you can also send a POST request to create a new entry. Since Binubuo is a random data generator, that also means that any requests that are supposed to create or alter data, do not actually do anything to the data (more on that later).

Let’s take a look at each request type in detail and with examples.

For this demo, we will be using the ADDRESS endpoint in the in the AdventureWorks set of endpoints.

Check out the video and then see the code below

The base endpoint for this is:

https://binubuo.com/api/data/standard/adventureworks/address

And if we wanted to fetch 3 rows it would be:

https://binubuo.com/api/data/standard/adventureworks/address?rows=3

curl -H @{"x-binubuo-key" = "ASDF1234"} -Method GET 'https://binubuo.com/api/data/standard/adventureworks/address?rows=3'

[
	{
		"AddressID": 1,
		"AddressLine1": "101 Bifeblet River",
		"AddressLine2": null,
		"City": "Norfolk",
		"StateProvinceID": 1,
		"PostalCode": "32837",
		"SpatialLocation": "POINT (12.310645 55.830546)",
		"rowguid": "EF5D8F66-8BF8-FEBC-E053-1910000AE0AA",
		"ModifiedDate": "2021-12-16T11:39:49.772000"
	},
	{
		"AddressID": 2,
		"AddressLine1": "89 Jepatdaj Grove",
		"AddressLine2": null,
		"City": "Tempe",
		"StateProvinceID": 1,
		"PostalCode": "31404",
		"SpatialLocation": "POINT (47.2108472291059 13.4663625322871)",
		"rowguid": "EF5D8F66-8BF9-FEBC-E053-1910000AE0AA",
		"ModifiedDate": "2022-06-14T12:12:09.844000"
	},
	{
		"AddressID": 3,
		"AddressLine1": "223 Folow Heights",
		"AddressLine2": null,
		"City": "Austin",
		"StateProvinceID": 1,
		"PostalCode": "66204",
		"SpatialLocation": "POINT (47.5618905553489 13.2422943372905)",
		"rowguid": "EF5D8F66-8BFA-FEBC-E053-1910000AE0AA",
		"ModifiedDate": "2022-06-02T20:07:15.548000"
	}
]

GET for all and GET for one

Every service emits a number of rows, and if you are using TAG parameter to create predictable outcomes, you can use the combination of the TAG data and the datasets id (the first column by default) to simulate single record GET requests.

First let us request 3 rows with the TAG "always_same", so that whenever we request those 3 rows, the data will always be the same.

https://binubuo.com/api/data/standard/adventureworks/address?rows=3&tag=always_same

When we run the GET request with the tag, we always get the same data:

curl -H @{"x-binubuo-key" = "ASDF1234"} -Method GET 'https://binubuo.com/api/data/standard/adventureworks/address?rows=3&tag=always_same'

[
	{
		"AddressID": 1,
		"AddressLine1": "317 Jakowre Lane",
		"AddressLine2": null,
		"City": "Shreveport",
		"StateProvinceID": 3,
		"PostalCode": "59715",
		"SpatialLocation": "POINT (48.1237104813086 13.5900161807663)",
		"rowguid": "EF5D97D6-D56B-D19F-E053-1910000A54A8",
		"ModifiedDate": "2022-03-31T01:40:28.100000"
	},
	{
		"AddressID": 2,
		"AddressLine1": "74 Naro Pass",
		"AddressLine2": null,
		"City": "Barre",
		"StateProvinceID": 3,
		"PostalCode": "02893",
		"SpatialLocation": "POINT (47.8896811220523 13.7079228199031)",
		"rowguid": "EF5D97D6-D56C-D19F-E053-1910000A54A8",
		"ModifiedDate": "2021-12-10T17:22:36.263000"
	},
	{
		"AddressID": 3,
		"AddressLine1": "157 Jeli Manor",
		"AddressLine2": null,
		"City": "Missoula",
		"StateProvinceID": 3,
		"PostalCode": "99901",
		"SpatialLocation": "POINT (47.1501572301536 13.9740929965564)",
		"rowguid": "EF5D97D6-D56D-D19F-E053-1910000A54A8",
		"ModifiedDate": "2022-03-04T06:43:13.341000"
	}
]

So if we wanted to look at only a specific record from that result, let us take a look at the record with AddressID 2. So following standard REST protocol, we can request that simply by changing our GET request to include the id:

https://binubuo.com/api/data/standard/adventureworks/address/2?rows=3&tag=always_same

curl -H @{"x-binubuo-key" = "ASDF1234"} -Method GET 'https://binubuo.com/api/data/standard/adventureworks/address/2?rows=3&tag=always_same'

{
	"AddressID": 2,
	"AddressLine1": "74 Naro Pass",
	"AddressLine2": null,
	"City": "Barre",
	"StateProvinceID": 3,
	"PostalCode": "02893",
	"SpatialLocation": "POINT (47.8896811220523 13.7079228199031)",
	"rowguid": "EF5D97D6-D577-D19F-E053-1910000A54A8",
	"ModifiedDate": "2021-12-10T17:22:36.263000"
}

It is important that you keep the rows and tag with the same values, if you want the same detail data as the data you got back from your general request. If you do not add the tag or rows parameter or use different values, data will be different, but the request will still work.

But what if I want to create or delete?

You can call the REST endpoints with POST and DELETE as well. They will give you back dummy responses and no actual records will be created or deleted, as all synthetic data on Binubuo is created on the fly and randomly. So to send a delete request it would be:

DELETE

curl -H @{"x-binubuo-key" = "ASDF1234"} -Method DELETE 'https://binubuo.com/api/data/standard/adventureworks/address/2' 


StatusCode        : 204
StatusDescription : No Content
Content           :
RawContent        : HTTP/1.1 204 No Content
                    Connection: keep-alive
                    Content-Type: text/plain;charset=utf-8
                    Date: Fri, 09 Dec 2022 03:31:30 GMT
                    Server: nginx/1.20.1

And to simulate a create/POST request:

POST

curl -H @{"x-binubuo-key" = "ASDF1234"} -Method POST 'https://binubuo.com/api/data/standard/adventureworks/address'


StatusCode        : 204
StatusDescription : No Content
Content           :
RawContent        : HTTP/1.1 204 No Content
                    Connection: keep-alive
                    Content-Type: text/plain;charset=utf-8
                    Date: Fri, 09 Dec 2022 03:32:57 GMT
                    Server: nginx/1.20.1

Again, anything POST’ed or DELETE’d will not be physically done. These are only proxy REST endpoints. Anything can be send in the body, as it will just be ignored at execution time.

Don't have an account yet?

If you don't have an account on Binubuo yet, you can create one real quick. Just click "Sign up" in the top right corner, and you are on your way to create all the synthetic data you could dream about.

Want to see how to get started: Get Started Guide

Get more guides and help from the blog

Youtube Channel

Follow Binubuo on Twitter:


If you already have an account on RapidAPI, you can use your account to access Binubuo

Connect on RapidAPI