Testing and Prototyping for REST API Data Ingestion with JSONPlaceholder

JSONPlaceholder is a web service that offers REST API endpoints for example JSON data. If you needs to experiment with REST API quickly, this is a really great tool that you can use. It supports all the HTTP verbs. As for testing and prototyping REST API data ingestion, you can get 6 different JSON data that you can play with.

I created a Python function where you can obtain all the data by changing the resource name. The function uses the request module. Using json() on the response object can converts it into a Python dictionary. In a nutshell, the function returns a dictionary object from the GET request.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
def json_ph_api(resource):
    '''Get example json data from jsonplaceholder.typicode.com.
    Returns Python dictionary object'''

    json_data = None
    endpoint = 'https://jsonplaceholder.typicode.com/{}'.format(resource)
    print('Target endpoint is {}'.format(endpoint))
    r = requests.get(endpoint)
    if r.status_code == 200:
        print('API Call Successful')
        # data returned with r.json() is a dictionary object
        json_data = r.json()
    else:
        print('API call failed with status code: {}'.format(r.status_code))
    return json_data

Once you get the data, you can transform and load it into databases to create your own data ingestion code.

Pretty cool.

Data Engineering
Sending XML Payload and Converting XML Response to JSON with Python

If you need to interact with a REST endpoint that takes a XML string as a payload and returns another XML string as a response, this is the quick guide if you want to use Python. If you want to do it with Node.js, you can check out the post …

Data Engineering
Sending XML Payload and Converting XML Response to JSON with Node.js

Here is the quick Node.js example of interacting with a rest API endpoint that takes XML string as a payload and return with XML string as response. Once we get the response, we will convert it to a JSON object. For this example, we will use the old-school QAS (Quick …

Data Engineering
Downloading All Public GitHub Gist Files

I used to use plug-ins to render code blocks for this blog. Yesterday, I decided to move all the code into GitHub Gist and inject them from there. Using a WordPress plugin to render code blocks can be problematic when update happens. Plugins might not be up to date. It …