The World’s Most Narcissistic API, by ChatGPT


ChatGPT wrote me an API, that informs people of my doings, almost perfectly.

August 2023

Summary

The “world’s most narcissistic API,” which reveals what I’m likely doing at any given time, is now live. You can access it here: https://www.davidchataway.com/api.php or through any HTTP GET request to the API (application programming interfaces) endpoint (see code at the end of the post). Accessing the API endpoint will output, in JSON format, a string that is a function of the day and time.

Surprisingly, I didn't write this API; it was created by ChatGPT. Its skill in doing so has convinced me that large language models (LLMs) are indeed proficient at simple programming tasks.

I prompted ChatGPT to write a simple API for my web server because I had been interested in two things: 1) testing the code writing abilities of large language models, and 2) using APIs for future pet projects that require information exchange. Since the API doesn't provide any real-time information, I don't expect it to receive many requests. Nonetheless, it might save me from getting a few "Hey, what are you up to?" texts from my mom.

ChatGPT’s programming ability saved me a lot of time, especially with syntax and repetitive code blocks. I only needed four prompts to create the PHP API and the Python script (refer to the images below). Even after hearing about the programming prowess of LLMs, it was quite impressive.

However, ChatGPT did show some limitations. It made some “system-context mistakes” by being unable to consider the properties of the virtual machine. For example, I had to specify the Python interpreter using a shebang. Additionally, the content it generated wasn't personalized. Still, the necessary edits took less time than if I had written the code myself. I'm sure I'll use ChatGPT or other LLMs in the future for other programming tasks.

ChatGPT prompts

Python code to access the API endpoint

References

Image edited from this image by storyset on Freepik: https://www.freepik.com/free-vector/api-concept-illustration_28772962.htm