この記事はHamee Advent Calendar 2016の15日目の記事です。 今回は、ElixirのWebフレームワークPhoenixを使って、QiitaのAdvent Calendar 2016ランキングをJSONで返すWebAPIを構築してみます。 調べているとDBを利用する場合の記事が多く、DBを利用しない場合に上手く動作しなかったので、DBを使わない場合のの実装方法をまとめておきます。 やること Phoenixのインストール ElixirによるWebスクレイピング JOSN形式でスクレイピング結果を返す 前提条件 Elixirの環境構築済み インストール 詳細は公式のインストールガイドをご参照ください。 Phoenixのインストール 以下のコマンドでPhoenixをインストールします。 $ mix archive.install https://github.com/pho
Go言語で作るJson Web Tokenを用いたセキュアなAPIをインフラ構築自動化技術を用いて(Docker, Terraform, Ansible)構築GoCircleCIDockerAnsibleTerraform 初めに 著者はGo言語、インフラ構築自動化技術に関する知識はあまりないので、知識のある上級者は適切なアドバイスなり、間違いの指摘をして頂けると幸です。 このようなシチュエーションを想定しています。 ある日、上司からこんな無茶ぶりが・・・ 「君、優秀なんだね。Go言語が良いみたいだからGo言語でセキュアなAPIを軽く作っておいてよ。ついでにインフラ構築自動化も流行ってるから、導入して実行環境の構築も自動化しといて」 という無茶ぶりされたときにあなたはこのようなまなざしを上司に向けるでしょう。 安心して下さい。そんなあなたのためにこの記事を書きました。笑 冗談はさておき、本
この記事はGoCon 2016 springで話す内容を圧縮するためのものです。 WebサービスのAPI仕様を記述したりするためのそれなりに有名な仕様について、筆者(@vvakame)の私見を述べていく。 なお、Google Trendの結果を見ると…。 仕様を調べてSwaggerを選択する事にしたのは1年弱程度前のはずなので、もし "今はそれもうできるよ!" とかあったらコメントなどで教えてください。 RAML RESTful API Modeling Language なので、手書きを前提にしている。 YAMLで頑張って仕様を書く。 Spec APIs Explorerっぽいものもあるっぽい。 総評 比較的広く使われているようでパワを感じる。 まず仕様が先というスタイルなのがめんどくさそう。 YAMLなのがちょっとイヤ。 RAMLからGoとJavaScript(TypeScript)向
概要 アプリの開発を進めるには、APIの仕様 + API仕様通りのレスポンスを返すモックがあると捗る モックを簡単に効率良く作成する方法を調査 調査・検証 1.自分で仕様から書き起こす 長所 好きな言語で書ける 普段書かない言語を選択すればスキルアップ 短所 地味に大変 実際に使うときが面倒(ローカルか開発サーバ) 使いまわせない 時間がかかる 仕様変更ごとにコードを修正 2.JSONSchemaからの生成 長所 JSON SchemaでAPIを設計することでfieldの型など仕様が明確になる。 APIのレスポンスが正しいかValidationするのに使える。 サーバ、クライアントどちらでもテストに使用できる ドキュメントを自動生成できる。 短所 書くのが大変 json_worldというRubyのDSLでJSON Schemaが書けるgemがある 参考 http://r7kamura.ha
jqというC言語で書かれた軽量のJSONパーサー(コンピュータが読みやすい表示になっているものを人間でも見やすくする感じのもの)の一種であるjqの機能をRに導入した{jqr}パッケージを試したのでメモ。 本家のjqでできることはだいたいできる(対応しているバージョンはjq 1.4)と思うけど、jq自体の経験がないのでよくわかっていない部分がある。ただ、APIラッパーのパッケージや関数を書くときに{jqr}がなかなか良さそうだ。 RubicureAPIと政府統計 e-Stat API使って試してみる。 なおJSONのような階層構造のあるデータをR上で可視化するのに{xmlview} や{jsonview}が便利である。 uribo.hatenablog.com 🔰 どういうときに使うのか ウェブAPIに対して有効なリクエストを送ると、JSON形式でコンテンツが帰ってくることが多い。HTTP
[2015-01-30] 政府統計の総合窓口(e-Stat)−API機能バージョン2.0の提供が始まった。以下は2.0に書き換えた。 [2015-12-21] 「からだにいいもの」にRで解析:政府統計の総合窓口(e-Stat)のAPIを利用したデータの取得例という記事が出たようだ(まだ読んでない)。 [2016-07-17] e-Stat APIバージョン2.1をRから使う,API 2.1になってCSVもどきが取れるようになったようだ。 はじめに 政府統計ポータル(e-Stat)と R でサンタさんの12月の出費動向を調べてみた - akiyoko blog はマウス操作の説明がほとんどなので,APIを使ってスマートにできないかと考え, WebAPI - e-Stat を使って統計情報を取得してみる - Qiita などを読んで勉強を始めた。しかし,R_Linux 師匠が RPubs -
こんにちは。 カヤックに新卒で入社し、フロントエンドエンジニアとして スロット制作を中心とした活動を続けている田島です。 どうぞお手柔らかによろしくお願いします。 さてさて、Webのフロントエンドエンジニアの場合、 何か作りたいアイデアを思いついてから世に公開するまでのスピードが コピーライターに次いで早いです。 また、リッチなコンテンツや大量のコンテンツを扱って何かしようというときには WebAPIをうまく活用すれば、自前でデータベースを作らずとも ササッと作って公開することもできます。 今回は、そうしたフロントエンド制作を豊かにするWebAPIの中から特に 面白いと思うものを7つ選び、実例を交えて紹介していきたいと思います。 1. MediaWiki API http://ja.wikipedia.org/w/api.php Wikipediaの情報を取得できるAPIです。 このAPI
Kotlinスタートブック を参考に、Android および Java で利用できる、HTTP クライアント、Retrofit を使用して、Web API (JSON)を Kotlinのモデルとして扱う。 驚くほど簡単。KotlinスタートブックはAndroidアプリをKotlinで作成するための要点が端的にまとめられている。個人的にはもう少し文章密度が高いほうが好みだが、手法をシンプルに知るにはこちらのほうが良いかも。 1.build.gradle (Module app) build.gradle に以下を追加、retrofitから、リアクティブプログラミングのRxJava、Googleが提供するJSONとJavaオブジェクトを相互変換ライブラリGSONの設定を行う dependencies { : def retrofitVersion = '2.4.0' compile "com.
RESASは「Regional Economy Society Analyzing System(地域経済分析システム)」の略。読み方は「リーサス」。市区町村別の産業・経済の情報が提供されており、APIを利用して生データをダウンロードできる。 トップページ - RESAS 地域経済分析システム ここでは、PythonからRESAS APIを利用してデータをJSONやCSV形式でダウンロードする方法を説明する。 RESAS APIの基本的な使い方 APIキーを取得 仕様と使い方 RESAS-API一覧 例: 都道府県コード データを取得 JSONで保存 pandas.DataFrameに変換 CSVで保存 例: 市区町村コード 都道府県を指定して個別にダウンロード 全都道府県のデータを一括ダウンロード pandas.DataFrameに変換して連結 CSVで保存 JSONで保存 例: 一人当
はてなブックマークAPIを使うと、特定のURLのブックマーク数や詳細情報(ブックマークした日時やユーザー、コメントなどの一覧)をシンプルなGETリクエストで取得できる。 はてな API一覧 - Hatena Developer Center 指定したURLとそれ以下のパスのURL(=指定したサイト内のURL)のブックマークの詳細情報はScrapyと組み合わせると一括で取得できる。ブックマークの合計数はAPIで取得可能。 以下の内容について説明する。 はてなブックマークAPIの種類と使い方 はてなブックマーク件数取得API はてなブックマークエントリー情報取得API はてなブックマークWebページで取得できる情報 Scrapyでクローリング・スクレイピング サイト内のURLのブックマーク数を一括取得 サイト内のURLのブックマーク日時・コメントなどを一括取得 pandasによる分析 なお、サ
スプレッドシートを Web API 化するアプローチとして Google Apps Script を使ったやり方があります。 最近、人気記事になっているのがまさにそのパターンですね。 3分で API を作って世の中にデプロイするライブコーディング〜今日から君もスピードスターエンジニア〜 しかし、Google Apps Script を使った手法には次のような弱点があるため、簡易的なものにしか使えません。1 URLを自由に設定できない リクエスト数など各種制限 本記事では、サーバーやクライアントなど好きな環境からスプレッドシートを読み込む手法の解説と、スプレッドシートをWebAPI化するサービスの作り方について記載します。 スプレッドシートの読み込みは、GAS使わなくても簡単にできますよ! Web API を動かしてみよう 読込対象のスプレッドシート デモ用として次のスプレッドシートを用意し
天気情報を取得できるAPIはたくさんありますが、 今回は、OpenWeatherMap - actual and forecast weatherという無料サービスを使って、天気情報をjsonで取得します。 都市名で取得する http://api.openweathermap.org/data/2.5/weather?q="都市名","国" //例 http://api.openweathermap.org/data/2.5/weather?q=Tokyo,jp http://api.openweathermap.org/data/2.5/weather?lat="緯度"&lon="経度" //例 http://api.openweathermap.org/data/2.5/weather?lat=35&lon=140 { "base": "cmc stations", "clouds":
まずはインポート import pandas as pd CSV, TSV pd.reed_csv(filename, header=None, names=['A', 'B'], index_col='A', ...) # filename以外は省略可能 # pd.reed_table()というメソッドもある。これは、sep=""パラメーターで区切り文字を指定できる。デフォルトはタブ Excel xls = pd.ExcelFile(filename) df = xls.parse('sheet_name') JSON import json json_data = json.loads(json_text) name = json_data[0]['name'] XML from lxml import objectify parsed = objectify.parse(open(x
自分が読んだ本を記録できるSNS、ブクログ。 私も愛顧しているのだけれども、どうやらAPIがあるらしい。 ブクログのAPIを使って本の情報をjQueryで取得してみた http://backyard.chocolateboard.net/201204/booklog-jquery そこで、Pythonを利用してブクログから自分の本棚の情報を取得するスクリプトを書いたので、メモがてらに公開する。 # /usr/local/bin/python # -*- coding: utf-8 -*- import json import urllib2 booklogID = "xxx" url = 'http://api.booklog.jp/json/%s' % booklogID data = json.load(urllib2.urlopen(url)) tana = data["tana"]
本日、はてな内のお気に入りのユーザー情報を取得できる「お気に入りAPI」(Favorites API)を公開しました。 以下のURLにアクセスすると、JSON形式でお気に入りユーザーの名前の一覧を取得することができます。 http://www.hatena.ne.jp/ユーザー名/favorites.json お気に入りユーザーとは、はてなアンテナで日記を購読していたり、1ヶ月内に☆をつけたりしたことがあるなど、はてなの各サービスでの活動から相手に対して何らかの行動を行っているユーザーのことを指します。 はてなのお気に入りAPIは、以下の情報を集約して情報を集約して配信しています。個別のサービスからのみお気に入りの情報を取得することも可能です。 はてなダイアリー 最近はてなダイアリーにトラックバックを飛ばしたり、コメントを書き込んだ相手のユーザー http://d.hatena.ne.jp
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く