An Elixir client for the Yelp Fusion API (aka Yelp's API v3).
See the Yelp API docs here.
See the Hex documentation for more information.
Add :yelp_ex
to your mix.exs
file as a dependency and to
your extra_applications
list:
def application do
[extra_applications: [:logger, :yelp_ex]]
end
defp deps do
[{:yelp_ex, "~> 0.2.0"}]
end
Important: You must use YelpEx
version 0.2.0 or higher due
to a change in how the Yelp Fusion API authenticates.
Then, run: mix do deps.get, compile
In order to use YelpEx
, you need to create an application on
Yelp's developer website.
After you do this, you will get an "App ID" and an "App Secret".
Yelp uses an API key to authenticate.
Before starting your application, you will need to save your Yelp API key as an environment variable...
One way to do this is to create a file called .env
in your
project root with the following:
export YELP_API_KEY="<YOUR_YELP_API_KEY>"
Execute the file from the command line:
$ source .env
When you start your application, an authenticated, supervised
YelpEx.Client
will also be started.
$ iex -S mix
Click endpoint links to see all valid parameters that can be
passed in options
.
/businesses/search Endpoint
iex> options = [params: [sort_by: "distance", longitude: -75.145101, latitude: 39.54364]]
[params: [sort_by: "distance", longitude: -75.145101, latitude: 39.54364]]
iex> YelpEx.Client.search(options)
{:ok, {<RESPONSE>}}
iex> YelpEx.Client.search!(options)
{<RESPONSE>}
/businesses/search/phone Endpoint
iex> options = [params: [phone: "+14159083801"]]
iex> YelpEx.Client.search_phone(options)
{:ok, {<RESPONSE>}}
iex> YelpEx.Client.search_phone!(options)
{<RESPONSE>}