Gyazo API
公開API
https://api.gyazo.com/api/images
OAuth
https://gyazo.com/oauth/authorize
画像へのリンク
元画像
https://gyazo.com/:image_id/raw
APIの応答の型が複雑なので、いくつか型定義しておく
types.tstype ISOTime =
`${number}-${number}-${number}T${number}:${number}:${number}.${number}Z`;
type GyazoType = "jpg" | "png" | "gif";
type ThumbURL = `https://thumb.gyazo.com/thumb/${number}${
"" | "_w" | "_crop"
}/${string}.${GyazoType}`;
type ThumbWebpURL = `https://thumb.gyazo.com/thumb/${number}${
"" | "_w" | "_crop"
}/${string}.webp`;
type IThumbURL = `https://i.gyazo.com/thumb/${number}${
"" | "_w" | "_crop"
}/${string}.${GyazoType}`;
type IThumbWebpURL = `https://i.gyazo.com/thumb/${number}${
"" | "_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;
}
types.ts/** 座標を表す
* - 左上が原点
* - 単位はpx
*/
interface Point {
x: number;
y: number;
}
/** 四角形の領域を表す */
interface BoundingPoly {
vertices: [Point, Point, Point, Point];
}
types.tsinterface 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
から取得できる
types.tsinterface User {
name: string;
desc: string | null;
icon_url: string;
pro: boolean;
}
types.tsinterface 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になる
};