BinaryJazz / genrenator

Random genre creation
https://binaryjazz.us/genrenator-api/
GNU General Public License v3.0
10 stars 0 forks source link

idea: extend API results to include url #15

Open jazzsequence opened 6 years ago

jazzsequence commented 6 years ago

In his LoopConf talk Dennis Snell talks about building on existing endpoints as requirements change, rather than rewriting and restructuring APIs or adding additional endpoints for no good reason.

What I'm thinking is that if you have a result like this:

[
  "wind sheffield invasion",
  "gangsta tunes emo",
  "micro-fox",
  "electrobop",
  "lute blues"
]

We could build in the urls for those genres (in this case, same would apply to stories) into the response, e.g.:

[
  {
    "wind sheffield invasion": {
       "url": "https://binaryjazz.us/genrenator/?genre=wind%20sheffield%20invasion"
    }
  },
  {
    "gangsta tunes emo": {
       "url": "https://binaryjazz.us/genrenator/?genre=gangsta%20tunes%20emo"
    }
  },
  {
   "micro-fox": {
      "url": "https://binaryjazz.us/genrenator/?genre=micro-fox"
    }
  },
  {
    "electrobop": {
       "url": "https://binaryjazz.us/genrenator/?genre=electrobop"
    }
  },
  {
    "lute blues": {
       "url": "https://binaryjazz.us/genrenator/?genre=lute%20blues"
    }
  }
]

The result would be more data served by the api, and we'd be able to potentially pull the URLs from the API (and therefore the dynamic name generation in the shortcode from the API) rather than building it (in the shortcode) on the fly. This would potentially solve the issue in #14 as a side-effect.

jazzsequence commented 6 years ago

This may require some refactoring of the twitter bot if we did this. cc @allisonplus On the flip side, it would mean the twitter bot could tweet links to the genres.