<commit_before>Fishbase API
=======

Draft Fishbase API - using Ruby's Sinatra framework

`jq` is used below to make examples brief - get it at [http://stedolan.github.io/jq/](http://stedolan.github.io/jq/).

This is being developed on a local machine - will be on a public server soon (hopefully). Data is not included in this repo, so you can't actually follow the below instructions, unless you have the DB :)

## The endpoints so far

* `/heartbeat`
* `/species`
* `/genera`
* `/getfaoarea`

## Clone this repo

```sh
git clone <EMAIL>:ropensci/fishbaseapi.git
cd fishbaseapi
bundle install
```

## Start Sinatra

```sh
cd fishbaseapi
ruby api.rb
```

## Heartbeat

The root `localhost:4567` redirects to `/heartbeat` 

```sh
curl -L http://localhost:4567
# or equivalently curl http://localhost:4567/heartbeat
```

```sh
{
    "paths": [
        "/heartbeat",
        "/species/:id?<params>",
        "/genera/:id?<params>"<commit_msg>added more notes about setup<commit_after>Fishbase API
=======

Draft Fishbase API - using Ruby's Sinatra framework

`jq` is used below to make examples brief - get it at [http://stedolan.github.io/jq/](http://stedolan.github.io/jq/).

This is being developed on a local machine - will be on a public server soon (hopefully). Data is not included in this repo, so you can't actually follow the below instructions, unless you have the DB :)

## The endpoints so far

* `/heartbeat`
* `/species`
* `/genera`
* `/getfaoarea`

## Setup database

Uncompress the database dump, e.g.: `2013-12-13_10-53-23_fbapp.7z`. Then start mysql and load into mysql

```sh
mysql.server start
mysql -u root fbapp < 2013-12-13_10-53-23_fbapp.sql
```

The load step takes a while...

## Clone

```sh
git clone <EMAIL>:ropensci/fishbaseapi.git
cd fishbaseapi
```

## Setup

```sh
bundle install
```

## Start Sinatra

```sh
ruby api.rb
```

## Heartbeat

The root `localhost:4567` redirects to `/heartbeat` 

```sh
curl -L http://localhost:4567
# or equivalently curl http://localhost:4567/heartbeat
```

```sh
{
    "paths": [
        "/heartbeat",
        "/species/:id?<params>",
        "/genera/:id?<params>"
{'fraction_non_alphanumeric': 0.14694835680751173, 'fraction_numerical': 0.02488262910798122, 'mean_word_length': 3.6427015250544663, 'pattern_counts': {'":': 2, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3329097', 'n_tokens_mistral': 777, 'n_tokens_neox': 700, 'n_words': 236}