Project

tenkit

0.01
No release in over a year
Wrapper for Weatherkit API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.3.17
~> 2.8
~> 12.3
~> 3.0
~> 3.8

Runtime

~> 0.21.0
~> 2.7.0
 Project Readme

Tenkit 天気ト

Gem GitHub Workflow Status

A wrapper for Apple's WeatherKit API in Ruby

A portmanteau of "tenki" the Japanese word for weather, and "kit", the end of WeatherKit.

This project is in beta, some of its API may be unstable, or possibly non-functional (like WeatherKit itself). We recommend pinning the version in your Gemfile until we get to a stable release, at which point we will be using Semantic Versioning.

Installation

Add to Gemfile

gem 'tenkit'

See Apple's instructions on how to Get Started with Weatherkit. Your WeatherKit API dashboard should be at this URL https://developer.apple.com/account/resources/services/weatherkit.

Usage

See Credentials for information on how to obtain the configuration values below.

Tenkit.configure do |c|
  c.team_id = ENV["APPLE_DEVELOPER_TEAM_ID"]
  c.service_id = ENV["APPLE_DEVELOPER_SERVICE_ID"]
  c.key_id = ENV["APPLE_DEVELOPER_KEY_ID"]
  c.key =  ENV["APPLE_DEVELOPER_PRIVATE_KEY"]
end

client = Tenkit::Client.new

lat = '37.323'
lon = '122.032'

client.weather(lat, lon)

Credentials

Once obtained, these values should be kept secret.

For Ruby you might use ENV variables, or a .env file not committed to git.

Rails projects will likely store these values encrypted in custom credentials, which can be commited to git.

APPLE_DEVELOPER_TEAM_ID

This is your Apple Team ID, taken from the top-right of your developer account certificates page:

screenshot example of where to find your team ID

APPLE_DEVELOPER_SERVICE_ID

This is a Service ID that you’ll need to create: https://developer.apple.com/account/resources/identifiers/list/serviceId It will be in the same style as an App ID, as a reverse domain name, e.g. “com.example.fancypantsweather”

APPLE_DEVELOPER_KEY_ID

Generate a new key: https://developer.apple.com/account/resources/authkeys/add Give it a name (not important but descriptive to you) and make sure to check “WeatherKit”

screenshot example of registering a new key

Make sure you download the key and keep it safe for the next credential. Use the generated Key ID as the value for APPLE DEVELOPER KEY ID.

APPLE_DEVELOPER_PRIVATE_KEY

This is the freshly downloaded private key, a .p8 file. P8 is a format that presents the private key in plain text (.p12 is a binary format). You may have seen these before, they look something like this:

-----BEGIN PRIVATE KEY-----
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA
-----END PRIVATE KEY-----

About

Maintained by: Super Basic