Adding a new provider to Snoop is simple and fully modular.
Follow these steps to integrate an additional real estate source.
- Navigate to:
server/provider
- Create a new file, e.g.:
newProvider.js
Each provider must export the following elements:
| Export | Description |
|---|---|
config |
Provider configuration and normalization rules |
metaInformation |
Metadata such as name and base URL |
init(sourceConfig, blacklistTerms) |
Initializes the provider with configuration |
getListings() |
(optional) Fetches and returns listings |
Example implementation:
import utils from '../utils/utils.js';
let appliedBlackList = [];
function normalize(o) {
const id = parseInt(o.id.substring(o.id.indexOf('_') + 1, o.id.length));
return Object.assign(o, { id });
}
function applyBlacklist(o) {
const titleNotBlacklisted = !utils.isOneOf(o.title, appliedBlackList);
const descNotBlacklisted = !utils.isOneOf(o.description, appliedBlackList);
return titleNotBlacklisted && descNotBlacklisted;
}
const config = {
url: null,
//this is the container wrapping the search listings
crawlContainer: '#result-list-stage .item',
crawlFields: {
id: '@id',
price: 'div[id*="selPrice_"] | trim',
size: 'div[id*="selArea_"] | trim',
title: '.item a img@title',
link: 'a[id*="lnkImgToDetails_"]@href',
address: '.item .box-25 .ellipsis .text-100 | removeNewline | trim',
},
paginate: '#idResultList .margin-bottom-6.margin-bottom-sm-12 .panel a.pull-right@href',
normalize: normalize,
filter: applyBlacklist,
};
export const init = (sourceConfig, blacklistTerms) => {
config.url = sourceConfig.url;
appliedBlackList = blacklistTerms || [];
};
export const metaInformation = {
name: "ProviderName",
baseUrl: "https://www.new-provider.de",
imageBaseUrl: "https://image.new-provider.de",
id: "providerId",
};
export { config };All providers inside server/provider are automatically discovered and registered by
snoop — no manual import required.
All providers inside server/provider are automatically discovered and registered for testing. No test file needed
Add your provider entry to server/test/provider/testProvider.json:
{
"newProvider": {
"url": "https://api.newprovider.com/listings",
"isActive": true
}
}Execute the full test suite to verify your provider:
cd server
npm testWe welcome all contributions that make Snoop better!
Follow the standard GitHub workflow:
# 1. Fork the repository
git fork https://github.com/code-by-fh/snoop.git
# 2. Create a new branch
git checkout -b feature/my-awesome-feature
# 3. Make your changes
git commit -m "feat(provider): add NewProvider integration"
# 4. Push to your fork
git push origin feature/my-awesome-feature
# 5. Open a Pull Request on GitHub 🚀Please ensure:
- Code is formatted via Prettier
- All tests pass (
npm test) - New code follows ESLint rules and includes doc comments