Responding to cURL with a JSON Resumé 📚

February 2, 2017
tutorial curl json

Over the past couple of months I’ve received numerous messages asking me how I’ve made this website respond to cURL requests with JSON (a little like JSON Resumé). If you’re out of the loop, you can either curl or check out this GIF:

It’s super simple to setup — I’ve done it with nginx and with Caddy. All it does is:
1. Check the user agent on incoming requests to the root site (
2. If the user agent is cURL, respond with a JSON file

With nginx:

server {
  listen 80;
  root /home/you/www;

  location / {
    if ($http_user_agent ~* ^curl) {
      rewrite ^/$ "/path/to/about.json";

With Caddy, it’s even easier: {
    root /home/you/www
    rewrite {
        if {>User-Agent} has curl
        if {path} is /
        to /path/to/about.json

Thought this was neat? Tweet me!

If you liked this post, you’ll probably enjoy one of my other projects, 🐦 Try curl to see it in action!

comments powered by Disqus