Skip to content

EventRegistry class

gregorleban edited this page Sep 7, 2015 · 22 revisions

EventRegistry is the main class that you are going to need in order to send any kind of request to the Event Registry. You can create an instance of this class as follows:

from eventregistry import *
er = EventRegistry()

The constructor accepts several relevant parameters, that you can modify:

  • host [default: "http://eventregistry.org"]. The URL where the Event Registry is available. When testing some new features, you might need to specify a different URL.
  • logging [default: False]. Should the executed web requests be logged in the requests_log.txt file in the package directory?
  • minDelayBetweenRequests [default: 0.5]. What should be the minimum delay in seconds between two requests sent to Event Registry. Remember that each user has a daily request limit so don't spend the requests too fast.
  • repeatFailedRequestCount [default: -1]. In case a request fails (for example, timeout), how many times should it be repeated before giving up. Use -1 to repeat indefinitely.

Logging in

In case you are a registered user you might wish to log into Event Registry in order to be able to make more requests per day. You can achieve this by calling the EventRegistry.login() method and passing in the username and password. Alternatively, you can also create a settings.json file in the eventregistry package directory. The content of the file should be a simple JSON object:

{
	"username": "YOUR_USERNAME",
	"password": "YOUR_PASSWORD"
}

If this file will be found when creating the EventRegistry instance it will be automatically used for logging you in.

Methods