Gyazo API
公開API
https://api.gyazo.com/api/images
OAuth
https://gyazo.com/oauth/authorize
画像へのリンク
元画像
https://gyazo.com/:image_id/raw
APIの応答の型が複雑なので、いくつか型定義しておく
code:types.ts
type ISOTime =
${number}-${number}-${number}T${number}:${number}:${number}.${number}Z;
type GyazoType = "jpg" | "png" | "gif";
"" | "_w" | "_crop"
}/${string}.${GyazoType}`;
"" | "_w" | "_crop"
}/${string}.webp`;
"" | "_w" | "_crop"
}/${string}.${GyazoType}`;
"" | "_w" | "_crop"
}/${string}.webp`;
type PermalinkURL = https://gyazo.com/${string};
type IGyazoURL = https://i.gyazo.com/${string}.${GyazoType};
interface GridThumbs {
large_url: ThumbURL | null;
large_url_2x: ThumbURL | null;
large_url_webp: ThumbWebpURL | null;
large_url_webp_2x: ThumbWebpURL | null;
medium_url: ThumbURL | null;
medium_url_2x: ThumbURL | null;
medium_url_webp: ThumbWebpURL | null;
medium_url_webp_2x: ThumbWebpURL | null;
small_url: ThumbURL | null;
small_url_2x: ThumbURL | null;
small_url_webp: ThumbWebpURL | null;
small_url_webp_2x: ThumbWebpURL | null;
mobile_2x_url: IThumbURL | null;
mobile_2x_url_webp: IThumbWebpURL | null;
}
code:types.ts
/** 座標を表す
* - 左上が原点
* - 単位はpx
*/
interface Point {
x: number;
y: number;
}
/** 四角形の領域を表す */
interface BoundingPoly {
}
code:types.ts
interface Exif {
"Color Space": string;
"Components Configuration": string;
Compression: string;
"Custom Rendered": string;
"Date and Time": string;
"Date and Time (Digitized)": string;
"Exif Version": string;
FlashPixVersion: string;
Manufacturer: string;
Model: string;
Orientation: string;
"Pixel X Dimension": string;
"Pixel Y Dimension": string;
"Resolution Unit": string;
Software: string;
"X-Resolution": ${number};
"Y-Resolution": ${number};
"YCbCr Positioning": string;
ok: "ok";
}
Exifは他にもproperitesがあるようだ
GNSS系がある
多分撮影機種に応じてpropertiesが変わる
共通するproperitesはexif_normalizedから取得できる
code:types.ts
interface User {
name: string;
desc: string | null;
icon_url: string;
pro: boolean;
}
code:types.ts
interface Image {
alias_id: string;
image_id: string; // 無料ユーザーで10枚以上取得しようとしたとき空文字になる
thumb_url: ThumbURL;
thumb_url_2x: ThumbURL;
thumb_url_webp: ThumbWebpURL;
thumb_url_webp_2x: ThumbWebpURL;
file_only: boolean;
has_files: boolean;
file_types: string | null;
file_names: string | null;
cross_origin: "anonymous";
access_policy: "anyone";
accessible: boolean;
created_at: ISOTime;
updated_at: ISOTime | null;
exif_captured_at: ISOTime | null;
deletable: boolean;
desc: string;
grid_thumbs: GridThumbs;
metadata?: {
app: string;
title: string;
url: string;
desc: string;
ocr_started: boolean;
exif: Exif;
exif_status: {
captured_at: "from_created_at";
ok: true;
msg: "ok";
},
exif_normalized: {
timezone: "unknown;
}
},
non_cropped_thumb: {
scaled: {
scale: 2;
size: 400;
url: ThumbURL;
};
url: ThumbURL;
};
owned: true;
permalink_path: /${string} | null; // 無料ユーザーで10枚以上取得しようとしたときnullになる
permalink_url: PermalinkURL | null; // 無料ユーザーで10枚以上取得しようとしたときnullになる
user: User | null; // 無料ユーザーで10枚以上取得しようとしたときnullになる
url: IGyazoURL | null; // 無料ユーザーで10枚以上取得しようとしたときnullになる
};
内部API
https://gyazo.com/:image_id.json
応答
OCR及びEXIFは、すでに解析済みならproでなくても取得できるようだ
詳細ページからは取得できないが、APIからなら取得できる
Proをやめても取得できるのはよくない設計な気もするが
code:types.ts
interface GyazoImage {
accessible: boolean;
image_id: string;
alias_id: string;
file_size: number;
metadata_is_public: boolean;
scale: {
width: number;
height: number;
scale: number;
};
type: GyazoType;
page_title: string;
updated_at: ISOTime | null;
exif_captured_at: ISOTime | null;
desc: string;
draw_src_id: string | null;
draw_materials: unknown | null;
deletable: boolean;
owned: boolean;
drawable: boolean;
is_pro: boolean;
access_policy: "anyone";
cross_origin: "anonymous";
url: IGyazoURL;
permalink_url: PermalinkURL;
permalink_path: /${string};
file_only: boolean;
has_files: boolean;
attached_files: unknown[];
thumb_url: ThumbURL;
poster_thumb_url: ThumbURL;
thumb1000: IThumbURL;
grid_thumbs: GridThumbs;
non_cropped_thumb: {
url: ThumbURL;
scaled: {
url: ThumbURL;
size: number;
scale: number;
};
};
user: User | null;
explicit: boolean;
categories: string[];
next: {
image_id: string;
alias_id: string;
permalink_url: PermalinkURL;
permalink_path: /${string};
};
prev: {
image_id: string;
alias_id: string;
permalink_url: PermalinkURL;
permalink_path: /${string};
};
has_mp4: boolean;
mp4_url: https://i.gyazo.com/${string}.mp4;
download_mp4_url: https://i.gyazo.com/download/${string}.mp4;
download_gif_url: https://i.gyazo.com/download/${string}.gif;
is_preview_gif: boolean;
has_audio: boolean;
has_voice: boolean;
boards: unknown[];
external_comments: unknown[];
metadata?: {
app: string;
title: string;
url: string;
desc: string;
ocr_started: boolean;
ocr: {
locale: string;
description: string;
boundingPoly: BoundingPoly;
} | {
description: "";
};
ocrAnnotations: {
description: string;
boundingPoly: BoundingPoly;
}[] | null;
exif: Exif;
exif_status: {
captured_at: "from_created_at";
ok: true;
msg: "ok";
};
exif_normalized: {
timezone: "unknown";
} | {
timezone: "utc";
latitude: number;
longitude: number;
time: ISOTime;
};
};
}
/api/internal
internalとなっているが、robots.txtではとくに制限されていないので、勝手に使っても問題なさそう https://gyazo.com/api/internal/images
画像一覧を取得
URL paramerters
page (number)
per (number)
一度に取得する画像の最大数
timestamp (number)
なにこれ
応答
Image[]
PATCH https://gyazo.com/api/internal/images/:image_id
parameters
bodyにJSONとして送る
access_policy
"anyone": password解除
"passphrase": passwordかける
passphrase
access_policy: "passphase"のときのみ必要
password
https://gyazo.com/api/internal/search_histories
検索履歴を取得する
URL parameters
page (number)
paging
応答
SearchHistory[]
thumb系が常にあるかは調べてない
code:types.ts
interface SearchHistory {
id: string;
title: string;
pinned: boolean;
image: {
alias_id: string;
image_id: string;
thumb_url: ThumbURL;
thumb_url_2x: ThumbURL;
thumb_url_webp: ThumbWebpURL;
thumb_url_webp_2x: ThumbWebpURL;
file_only: boolean;
has_files: boolean;
file_types: string | null; // nullしか観測していない
file_names: string | null; // nullしか観測していない
cross_origin: "anonymous";
};
};
https://gyazo.com/api/internal/search_result
検索する
URL parameters
必須
per (number)
query (string)
検索文字列
これを抜かすと500 internal errorが発生する
page (number)
timestamp (number)
応答
EXIFとサムネURL周りのpropertiesはoptionalかも code:types.ts
interface SearchResults {
query: string;
engine: "Elasticsearch";
index: "image-20-kuromoji-filter",
start_indexing: boolean;
conditions: {
match_phrase: {
everything: string;
} | {
app: string;
};
}[];
number_of_captures: number;
captures: Image[];
}
https://gyazo.com/api/internal/images/:image_id/similar_images
関連画像
応答
Image[]
free userだと空配列が返ってくる
https://gyazo.com/api/internal/images/:image_id/close_date_images
前後にuploadされた画像
応答
code:types.ts
interface CloseDateImages {
before: Image[];
after: Image[];
}
https://gyazo.com/api/internal/images/:image_id/similar_metadata_images
各属性の関連画像
応答
free userだと空配列が返ってくる
code:types.ts
type SimilarMetadata = {
keyword: string;
images: Image[];
};
};
https://gyazo.com/api/internal/images/:image_id/near_images
近くの場所で撮影された画像
応答
code:types.ts
type NearImages = {
message: "no location";
count: 0;
images: [];
} | {
message: "ok";
count: number;
images: Image[];
};
https://gyazo.com/api/internal/boards/visits
https://gyazo.com/api/internal/images_summary
応答
なにこれ
code:types.ts
interface ImagesSummary {
monthly_counts: Record<number, Record<number, number>>;
}
https://gyazo.com/api/internal/boards/visits/images
画像の閲覧履歴を取得する
URL parameters
limit
取得する画像の最大数
cursor
paging用のID
応答
code:types.ts
interface VisitedImages {
cursor: string;
images:
}