BM: Baca dalam Bahasa Melayu
World 9: Power Tools
API, webhooks and Apps
You will learn: how programs talk to GitHub, and how to tell an API, a webhook and an App apart.
The problem
Your club wants a screen that shows new issues as they arrive. Do you sit and refresh GitHub all day?
Pick one answer.
Watch
An API: A service window for programs. A program asks, and the website answers with data. is a service window for programs. A program asks a question. GitHub answers with data. gh api lets you ask from the terminal.
Watch
Tap each point on the timeline.
A webhook: A doorbell: GitHub calls your web address when something happens. is a doorbell. When something happens, GitHub calls your web address. Nobody has to keep asking.
Try it
Ask, or get told? Sort each job.
Drag a card into a box. Or tap the card, then tap the box.
Watch
A GitHub App: A robot helper you install on chosen repos, with only the permissions it needs. is a robot helper. You install it on the repos you choose. Before you install, you see what it may do. Bots that label issues or check pull requests are often Apps.
Predict
An app only posts a weekly report. It asks to change your settings and read all your code. Do you install it?
Pick one answer.
Check
Good habit, or needs work? Swipe each one.
Swipe right for good, left for needs work. Or use the buttons.
Install an app only on the repos it needs
You did it!
You can now tell an API, a webhook and an App apart.
Go deeper (optional)
GitHub has a REST API and a GraphQL API. You can read public data without signing in. But the limits are lower. FahamLah’s mission checks do exactly that. Webhooks can sit on a repo, an organisation or an App. Apps use short-lived tokens, so a leak hurts less.
Bahasa Melayu
Kelab anda mahu skrin yang tunjuk issue baru sebaik ia masuk. Patutkah anda duduk dan muat semula GitHub sepanjang hari?
API ialah kaunter khas untuk program. Program tanya satu soalan. GitHub jawab dengan data. gh api biar anda bertanya dari terminal.
Webhook ialah loceng pintu. Bila sesuatu berlaku, GitHub panggil alamat web anda. Tiada siapa perlu asyik bertanya.
Tanya sendiri, atau diberitahu? Susun setiap kerja.
GitHub App ialah pembantu robot. Anda pasang ia pada repo pilihan anda. Sebelum pasang, anda nampak apa yang ia boleh buat. Bot yang label issue atau semak pull request selalunya App.
Satu app cuma hantar laporan mingguan. Ia minta izin ubah tetapan anda dan baca semua kod anda. Patutkah anda pasang?
Tabiat bagus, atau perlu baiki? Leret setiap satu.
Kini anda boleh bezakan API, webhook dan GitHub App.
You finished this before. Practice is always welcome!
Official docs: About the REST API · About webhooks · GitHub Apps overview · gh api
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?