An HTTP API serving JSON data for Code Union resources.
After cloning the repository, run
$ bundle install
$ bin/rake db:setup
$ bin/foreman start
Note: See below if bundle exec
gives you an error along the lines of
Your Ruby version is 2.1.5, but your Gemfile specified 2.0.0
Assuming access the following heroku apps:
- Production:
[email protected]:api-codeunion-io.git
- Staging:
[email protected]:api-codeunion-io-staging.git
We deploy by:
- Pushing to the appropriate remote (staging first! Then production)
- Running any migrations
- Smoke-testing
An example terminal session is as follows:
$ git push staging
...
$ heroku run bin/rake db:migrate --app api-codeunion-io-staging
...
$ curl http://api-codeunion-io-staging.herokuapp.com/v1/search?query=JavaScript
Heroku recommends we specify the version of Ruby to use in our
Gemfile, which we do. We read the version from an environment
variable named CUSTOM_RUBY_VERSION
. Otherwise, we use Heroku's
default Ruby version of 2.0.0
.
If you want to use a different version of Ruby locally, just set the
CUSTOM_RUBY_VERSION
environment variable by adding a line like this to
~/.bash_profile
:
export CUSTOM_RUBY_VERSION="2.1.5"
The base URL is https://api.codeunion.com/v1/
.
As of now no authentication is required.
# Creates or updates a given resource
bin/rake resources:create[exercise,https://github.com/codeunion/rpm-calculator]
Find resources whose text contains a particular query
GET /v1/search?:query_params
Name | Type | Description | Required |
---|---|---|---|
query | string | Search query | true |
category | string | See supported categories in app/models/resource.rb |
false |
GET /v1/search?category=examples&query=REST%20API
[
{
"name": "overheard-server",
"description": "Example project for a web app that stores and shares hilarious, out of context quotess and quips.",
"private": false,
"url": "https://github.com/codeunion/overheard-server",
"category": "examples",
"tags": [
"ruby",
"sinatra",
"datamapper",
"sqlite"
],
"access": [
"public",
"students",
"staff"
],
"license": true,
"has_wiki": false,
"notes": "",
"excerpt": "<match>REST</match> <match>API</match> to add and list Overheards\n\nFor a list of planned and implemented features, known bugs, etc. check the\n[CHANGELOG"
}
]