{"id":13509582,"url":"https://github.com/jeffutter/particle-elixir","last_synced_at":"2025-04-12T03:14:30.615Z","repository":{"id":62430284,"uuid":"65327869","full_name":"jeffutter/particle-elixir","owner":"jeffutter","description":"An Elixir Client for the Particle Cloud API","archived":false,"fork":false,"pushed_at":"2019-05-29T15:55:35.000Z","size":50,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T03:14:25.598Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeffutter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-09T20:59:15.000Z","updated_at":"2024-02-22T10:50:07.000Z","dependencies_parsed_at":"2022-11-01T20:17:35.090Z","dependency_job_id":null,"html_url":"https://github.com/jeffutter/particle-elixir","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffutter%2Fparticle-elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffutter%2Fparticle-elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffutter%2Fparticle-elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffutter%2Fparticle-elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeffutter","download_url":"https://codeload.github.com/jeffutter/particle-elixir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248510001,"owners_count":21116130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:01:09.908Z","updated_at":"2025-04-12T03:14:30.597Z","avatar_url":"https://github.com/jeffutter.png","language":"Elixir","funding_links":[],"categories":["Third Party APIs"],"sub_categories":[],"readme":"# Particle\n\n[![Build Status](https://travis-ci.org/jeffutter/particle-elixir.svg?branch=master)](https://travis-ci.org/jeffutter/particle-elixir)\n[![Hex.pm](https://img.shields.io/hexpm/v/particle.svg?maxAge=2592000)](https://hex.pm/packages/particle)\n[![Inline docs](http://inch-ci.org/github/jeffutter/particle-elixir.svg)](http://inch-ci.org/github/jeffutter/particle-elixir)\n[![Deps Status](https://beta.hexfaktor.org/badge/all/github/jeffutter/particle-elixir.svg)](https://beta.hexfaktor.org/github/jeffutter/particle-elixir)\n[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n\nParticle Cloud API Client for Elixir:\n\nThis is an unofficial client for the [Particle IoT platform's HTTP API](https://docs.particle.io/reference/api/). \n\n## Usage\n\nInstallation\n\n```elixir\ndef deps do\n  [{:particle, \"~\u003e 0.1.0\"}]\nend\n```\n\nand run `mix deps.get`. Now, list the :particle application as your application dependency:\n\n```elixir\ndef application do\n  [applications: [:particle]]\nend\n```\n\n## Configuration\n\nYou will need to set the following configuration variables in your `config/config.exs` file:\n\n```elixir\nuse Mix.Config\n\nconfig :particle,\n  particle_key: System.get_env(\"PARTICLE_KEY\")\n```\n\n## Stream Usage\n\nCreate a module responsible for the handling of the events. Customize `handle_events` for your application.\n\n```elixir\ndefmodule MyApp.ParticleEventHandler do\n  alias Experimental.GenStage\n  alias Particle.Stream\n\n  use GenStage\n\n  def start_link() do\n    GenStage.start_link(__MODULE__, :ok, name: __MODULE__)\n  end\n\n  def init(:ok) do\n    # Starts a permanent subscription to the broadcaster\n    # which will automatically start requesting items.\n    {:consumer, :ok, subscribe_to: [Stream]}\n  end\n\n  def handle_events(events, _from, state) do\n    IO.inspect events\n    {:noreply, [], state}\n  end\nend\n```\n\nStart the workers in the `Application`.\n\n```elixir\ndefmodule MyApp do\n  use Application\n  alias Particle.Stream\n\n  def start(_type, _args) do\n    import Supervisor.Spec\n\n    children = [\n      worker(Particle.Stream, [\"https://api.particle.io/v1/devices/events/status\", Particle.Http, [name: Stream]]), # define url here\n      worker(MyApp.ParticleEventHandler, [])\n    ]\n    opts = [strategy: :one_for_one, name: MyApp.Supervisor]\n    Supervisor.start_link(children, opts)\n  end\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffutter%2Fparticle-elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeffutter%2Fparticle-elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffutter%2Fparticle-elixir/lists"}