Skip to main content

Access to Breinify's DigitalDNA API

Project description

Breinify API Python Library

Breinify’s DigitalDNA API puts dynamic behavior-based, people-driven data right at your fingertips.

Step By Step Introductions

What is Breinify’s DigitialDNA

Breinify’s DigitalDNA API puts dynamic behavior-based, people-driven data right at your fingertips. We believe that in many situations, a critical component of a great user experience is personalization. With all the data available on the web it should be easy to provide a unique experience to every visitor, and yet, sometimes you may find yourself wondering why it is so difficult.

Thanks to Breinify’s DigitalDNA you are now able to adapt your online presence to your visitors needs and provide a unique experience. Let’s walk step-by-step through a simple example.

Quick start

Step 1: Download the Library

Download the library from PyPi and install it with

pip3 install breinify-api

or download the source from github and run

python3 setup.py install

Step 2: Integrate the library

Integrate the Library into your Python 3 project by importing the library in the relevant blocks of code.

import breinify

Step 3: Configure the library

In order to use the library you need a valid API-key, which you can get for free at https://www.breinify.com. In this example, we assume you have the following api-key:

772A-47D7-93A3-4EA9-9D73-85B9-479B-16C6

##this is a valid API key
apiKey = "938D-3120-64DD-413F-BB55-6573-90CE-473A"

brein = Breinify(apiKey)

The Breinify class is now configured with a valid configuration object.

Step 4: Start using the library

Placing activity triggers

The engine powering the DigitalDNA API provides three endpoints. The first endpoint is used to inform the engine about the activities performed by visitors of your site. The activities are used to understand the user’s current interest and infer the intent. It becomes more and more accurate across different users and verticals as more activities are collected. It should be noted, that any personal information is not stored within the engine, thus each individual’s privacy is well protected. The engine understands several different activities performed by a user, e.g., landing, login, search, item selection, or logout.

For this example, pretend that a user named “John Doe” is logged in to your site with his email address (john.doe@email.com) is viewing the page “www.example.com”. You can log this by executing:

from breinify import User
#create a user you are interested in with their email and last name
example_user = User(email="john.doe@email.com")

brein.send_activity(example_user, "pageView", url="www.example.com")

The call will then be run asynchronously in the background.

Temporal Data Lookup

Looking Up a User’s Location’s Info

You may want to customize the user’s experience based on where they are. For example calling .. code:: python

#create a user you are interested in based on their ip. Other fields (coordinates, time, etc) can also be included example_user = User(ip=”143.127.128.10”)

result = brein.temporal_data(example_user)

will result in a dictionary of timely information for the location the ip address resolves to (San Jose), for example:

#wrap the result in json.dumps() for readability
print(json.dumps(result,indent=4))

{
    "time": {
        "epochDayName": "Monday",
        "localYear": 2016,
        "epoch": 1477945062,
        "timezone": "America/Los_Angeles",
        "localDay": 31,
        "epochSecond": 42,
        "epochMinute": 17,
        "epochDay": 31,
        "localMonth": 10,
        "localMinute": 17,
        "localDayName": "Monday",
        "epochHour": 20,
        "epochMonth": 10,
        "epochYear": 2016,
        "localFormatIso8601": "2016-10-31T13:17:42-07:00",
        "localSecond": 42,
        "localHour": 13,
        "epochFormatIso8601": "2016-10-31T20:17:42+00:00"
    },
    "holidays": [
        {
            "source": "United Nations",
            "types": [
                "SPECIAL_DAY"
            ],
            "holiday": "World Cities Day"
        },
        {
            "source": "Public Information",
            "types": [
                "HALLMARK"
            ],
            "holiday": "Halloween"
        }
    ],
    "weather": {
        "lastMeasured": 1477935065,
        "precipitation": {
            "precipitationType": "none",
            "precipitationAmount": 0.0
        },
        "windStrength": 1.4,
        "cloudCover": 48.0,
        "temperature": 13.161000000000001,
        "description": "scattered clouds",
        "measuredAt": {
            "lon": -121.767731,
            "lat": 37.23328
        }
    },
    "location": {
        "country": "US",
        "granularity": "city",
        "city": "San Jose",
        "lon": -121.827179,
        "lat": 37.366051,
        "state": "CA"
    }
}
Looking Up Information About a Location

Instead of looking up information based off a user’s location, you can just supply the location’s information directly. For example, you could get yesterday’s weather in San Francisco by running:

from breinify import Breinify
import time
import math

apiKey = "938D-3120-64DD-413F-BB55-6573-90CE-473A"

brein = Breinify(apiKey)

yesterday = math.floor(time.time()) - 24*60*60

result = brein.temporal_data(location_free_text="San Francisco, CA", unixtime = yesterday)

print("Yesterday in %s, the weather was %s with a temperature of %d F."%(result['location']['city'], result['weather']['description'], result['weather']['temperatureF']))

Which will print something similar to “Yesterday in San Francisco, the weather was overcast clouds with a temperature of 64 F.”

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brein_api-1.3.0-py3.5.egg (18.1 kB view details)

Uploaded Egg

File details

Details for the file brein_api-1.3.0-py3.5.egg.

File metadata

  • Download URL: brein_api-1.3.0-py3.5.egg
  • Upload date:
  • Size: 18.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.4

File hashes

Hashes for brein_api-1.3.0-py3.5.egg
Algorithm Hash digest
SHA256 a1f0c63b5dd6fa4420963dc78885b2a6864ca6368333dc5635b306aa8faf718c
MD5 8e5541adcb625cf256db9a215796db76
BLAKE2b-256 877c95230855995c222b24624de1e8c86e5172f383ede012086034dd0691c87e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page