Skip to content

Latest commit

 

History

History
99 lines (64 loc) · 1.66 KB

USAGE.md

File metadata and controls

99 lines (64 loc) · 1.66 KB

How to Use

Import

from ebscopy import edsapi

Credentials and Parameters

The API requires some credentials and parameters to accept connections. These can be defined in environment variables or explicitly passed to the relevant functions.

  • Implicit credentials:
s = edsapi.Session()
  • Explicit credentials:
s = edsapi.Session(user_id="user", password="pass", profile="profile", org="org", guest="n")

Sessions

Sessions are the main interface to the API. Creating a Session will implicitly make a Connection, or you can get a Connection from the POOL first and pass it to the Session.

  • Session with implicit Connection:
s = edsapi.Session()
  • Session with explicit Connection:
c = edsapi.POOL.get()
s = edsapi.Session(connection=c)

Search Results

Performing a search in a Session will return a Results object. This contains the raw data from the API, as well as some simplified data structures and functions.

  • Searching
s = edsapi.Session()
r = s.search("blue")
  • Pretty printing
r.pprint()
  • Accessing raw data
print r.records_raw[0]
  • Accessing simple data
print r.records_simple[0]

Retrieving Records

The search results contain only basic information on each Record; for more, call the retrieve function of the Result object.

  • Retrieve a record
rec = s.retrieve(r.record[0])
  • Pretty print a record
rec.pprint()
  • Print simple information
print rec.simple_title

Ending a Session

You should end Sessions when you are done with them.

s.end()