GithubHelp home page GithubHelp logo

dacog / foursquare_api_tools Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 120 KB

some functions to interact with foursquare using 'foursquare' package

License: MIT License

Python 100.00%
foursquare-api foursquare-client python pandas-dataframe pandas

foursquare_api_tools's Introduction

Foursquare api tools (foursquare_api_tools)

Some functions to interact with foursquare using 'foursquare' package

Small intro

I needed to get the venues around a coordinate for a project, but wanted to get them on a dataframe to play with the data using pandas.

I found https://pypi.python.org/pypi/foursquare/ which works really good, but still had to clean the result, thus this.

I've only tried this with [https://developer.foursquare.com/docs/api/configuration/authentication](Userless Auth from Foursquare). As I'm using foursquare package it should work with user authentication.

Installation

pip install foursquare

pip install git+https://github.com/dacog/foursquare_api_tools.git#egg=foursquare_api_tools

If you are using Jupyter Notebooks use:

!pip install foursquare

!pip install git+https://github.com/dacog/foursquare_api_tools.git#egg=foursquare_api_tools

Details

help(ft)

Help on module foursquare_api_tools.foursquare_api_tools in foursquare_api_tools:

NAME
    foursquare_api_tools.foursquare_api_tools

FUNCTIONS
    get_categories()
        Function to get a Pandas DataFrame of all categories in Foursquare as listed in https://developer.foursquare.com/docs/resources/categories
        It uses json_normalize to get nested information and return a DataFrame with main, sub and sub-sub categories name and ID
    
    venues_explore(client, lat, lng, limit=100, verbose=0, sort='popular', radius=2000, offset=1, day='any')
        funtion to get n-places using explore in foursquare, where n is the limit when calling the function.
        This returns a pandas dataframe with name, city ,country, lat, long, address and main category as columns
        Arguments: *client, *lat, *long, limit (defaults to 100), radius (defaults to 2000), verbose (defaults to 0), offset (defaults to 1), day (defaults to any)

Example of use

Import libraries

import foursquare as fs
from foursquare_api_tools import foursquare_api_tools as ft

Initialize the client

CLIENT_ID = 'YOUR_CLIENT_ID' # your Foursquare ID
CLIENT_SECRET = 'YOUR_SECRET' # your Foursquare Secret
VERSION = '20180605' # Foursquare API version`

this example is Userless Auth

# Construct the client object 
client = fs.Foursquare(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, version=VERSION)

Use the function

venues_explore(client,lat='40.7233',lng='-74.0030',limit=100)

Example

Here is an example on dataplatform.cloud.ibm.com https://gist.github.com/e26e21df3b93860e75fc374be89a1a53

Example image

More details about usage

def venues_explore(client,lat,lng, limit=100, verbose=0, sort='popular', radius=2000, offset=1, day='any'):
	'''funtion to get n-places using explore in foursquare, where n is the limit when calling the function.
	This returns a pandas dataframe with name, city ,country, lat, long, address and main category as columns
	Arguments: *client, *lat, *long, limit (defaults to 100), radius (defaults to 2000), verbose (defaults to 0), offset (defaults to 1), day (defaults to any)'''

foursquare_api_tools's People

Contributors

dacog avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.