https://github.com/smithsonian/edanrb
ruby connector for EDAN API
https://github.com/smithsonian/edanrb
Last synced: over 1 year ago
JSON representation
ruby connector for EDAN API
- Host: GitHub
- URL: https://github.com/smithsonian/edanrb
- Owner: Smithsonian
- License: other
- Created: 2013-11-14T19:53:38.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-11-16T14:20:19.000Z (over 12 years ago)
- Last Synced: 2025-04-11T03:07:02.712Z (over 1 year ago)
- Language: Ruby
- Size: 125 KB
- Stars: 4
- Watchers: 16
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.md
Awesome Lists containing this project
README
# EDAN API Ruby Library
This is for an initial exploration of a Smithsonian API.
Use of this library requires a name & password and is currently for developers who are registered volunteers.
Contact Info:
Sarah Allen
allensa@si.edu
## Usage
```
gem install edanrb
export EDANUSER=SECRETNAME
export EDANPASS=SECRETPASS
gem install json
irb
> require 'edan'
> eq = EDANQuery.new('myapp')
> res = eq.request('q=art&wt=json')
> res.code
=> "200"
> require 'json'
> JSON.parse(res.body)
=> {"responseHeader" ...
```
## Using the Gem with Rails 3.x+
### Add edanrb gem to your Gemfile:
```
gem 'edanrb'
```
Then, run the 'bundle install' command.
### Add authentication settings:
There are two ways to do this, you can create a file in your /config/initializer directory:
```
config/initializer/edanrb_settings.rb:
# specify the username and password for the EDAN API:
ENV['EDANUSER'] = "this_is_my_username"
ENV['EDANPASS'] = "this_is_my_password"
```
Alternatively, you can do this from the command line when you start your rails server if you do not want to commit auth info for security reasons.
```
> EDANUSER="this_is_my_username" EDANPASS="this_is_my_password" rails server
```
## That's it! Now you're ready to rock with EDAN.
Don't forget to add the 'require' statement to your controllers or other locations where you'll be calling edanrb methods:
```
require 'edan'
def hello_edan_world
eq = EDANQuery.new('myapp')
res = eq.request('q=art&wt=json')
json_res = JSON.parse(res.body)
end
```