This repository stores boilerplate templates and code examples for Apify Actor. The template helps you to get started with your Apify project quickly.
You can start using them right away in Apify command-line interface:
npm -g install apify-cli
apify create my-actor
It displays an interactive list of templates for you to choose from. See Apify CLI documentation for more details.
To run the template:
cd my-actor
apify run
The example templates provide a quick and easy way to get to know Apify actors. Just install the CLI and watch your actor run.
- Hello world - The smallest actor you will see today, it only takes input and generates output.
- Puppeteer single page - Load a single web page using Chrome and Puppeteer and extract data from it.
- Basic crawler - Crawl a list of URLs using raw HTTP requests.
You can find more code examples in the examples folder and in the Apify SDK documentation.
If you're already familiar with actors, you can use the following templates to bootstrap new projects quickly:
- Empty project - Template with very little boilerplate code.
- Cheerio crawler - Standard and up to date template for developing with CheerioCrawler.
- Puppeteer crawler - Standard and up to date template for developing with PuppeteerCrawler.
The template manifest can be fetched programmatically. Apify CLI uses this to always fetch the most up to date templates.
npm i @apify/actor-templates
const templates = require('@apify/actor-templates');
const manifest = await templates.fetchManifest();
All templates are stores in ./templates
directory.
For each template needs to create an archive of whole source code into ./dist/templates
directory.
The archive is used to to create a boilerplate template in apify CLI or other places in Apify system.
If you want to change template, you need to update the files and manifest.json
and then push to master. After pushing to master, the archive will be automatically built using Github actions.
Templates are propagated to Apify CLI templates, you can choose one of the templates when using the apify create
command.
The propagation happens after committing a new version of templates into master
branch. After tests succeeded the Github action
builds archives of each template and pushes these archives into the repository. The CLI command then uses those archives
to bootstrap your project folder. We did it this way because we can update template structure/code without publishing
any package to npm. It makes templates changes agile.
If you have any ideas for improvements, either submit an issue or create a pull request. For contribution guidelines and the code of conduct, see CONTRIBUTING.md.