A TypeScript library that enables programmatic interaction with daft.ie. Daft.ie has nationwide coverage and contains about 80% of the total available properties in Ireland.
This is a TypeScript port of the original Python daftlistings library.
npm install daftlistings-ts
import { Daft, SearchType, PropertyType, Location } from "daftlistings-ts";
async function searchProperties() {
const daft = new Daft();
// Set search parameters
daft.setSearchType(SearchType.RESIDENTIAL_RENT);
daft.setPropertyType(PropertyType.APARTMENT);
daft.setMinBeds(2);
daft.setMaxBeds(3);
daft.setMinPrice(1000);
daft.setMaxPrice(2000);
daft.setLocation(Location.DUBLIN_2);
try {
const listings = await daft.search(2); // Search first 2 pages
console.log(`Found ${listings.length} listings`);
listings.forEach((listing) => {
console.log(`${listing.title} - ${listing.price}`);
console.log(
`Bedrooms: ${listing.bedrooms}, Bathrooms: ${listing.bathrooms}`
);
console.log(`Link: ${listing.daftLink}`);
});
} catch (error) {
console.error("Search failed:", error);
}
}
searchProperties();
- Type Safety: Full TypeScript support with comprehensive type definitions
- Async/Await: Modern async/await syntax for all API calls
- Comprehensive Search: Support for all Daft.ie search parameters
- Location Support: Built-in support for all Irish locations
- Facility Filtering: Advanced facility filtering for properties
- Error Handling: Proper error handling with custom error types
- Distance Calculations: Built-in distance calculation between properties
The main class for searching properties on Daft.ie.
setSearchType(type: SearchType)
- Set the type of search (rental, sale, etc.)setPropertyType(type: PropertyType)
- Set the property type (apartment, house, etc.)setLocation(location: Location | string | (Location | string)[], distance?: Distance)
- Set search locationsetMinBeds(beds: number)
- Set minimum number of bedroomssetMaxBeds(beds: number)
- Set maximum number of bedroomssetMinBaths(baths: number)
- Set minimum number of bathroomssetMaxBaths(baths: number)
- Set maximum number of bathroomssetMinPrice(price: number)
- Set minimum pricesetMaxPrice(price: number)
- Set maximum pricesetSuitability(suitability: SuitableFor)
- Set suitability (male/female)setOwnerOccupied(occupied: boolean)
- Set owner occupied filtersetMinTenants(tenants: number)
- Set minimum number of tenantssetMaxTenants(tenants: number)
- Set maximum number of tenantssetMinLease(months: number)
- Set minimum lease length in monthssetMaxLease(months: number)
- Set maximum lease length in monthssetMinFloorSize(size: number)
- Set minimum floor sizesetMaxFloorSize(size: number)
- Set maximum floor sizesetAddedSince(addedSince: AddedSince)
- Set when property was addedsetMinBer(ber: Ber)
- Set minimum BER ratingsetMaxBer(ber: Ber)
- Set maximum BER ratingsetFacility(facility: Facility)
- Add a facility filtersetSortType(sortType: SortType)
- Set sort order
search(maxPages?: number): Promise<Listing[]>
- Execute the search
Represents an individual property listing.
id: string
- Unique listing IDtitle: string
- Property titleprice: string
- Price as displayed on Daft.iemonthlyPrice: number | string
- Monthly price (converted from weekly if needed)bedrooms: string | undefined
- Number of bedroomsbathrooms: string | undefined
- Number of bathroomslatitude: number
- Property latitudelongitude: number
- Property longitudedaftLink: string
- Direct link to the property on Daft.ieagentName: string
- Agent nameagentBranch: string
- Agent branchber: string
- BER ratingpublishDate: string
- Publication dateimages: any[]
- Property imageshasVideo: boolean
- Whether property has videohasVirtualTour: boolean
- Whether property has virtual tourhasBrochure: boolean
- Whether property has brochuresizeMetersSquared: number | string
- Floor area in square meters
asDict(): ListingData
- Get raw listing dataasDictForMapping(): MappingData
- Get data formatted for mappingdistanceTo(location: Listing | Coordinate): number
- Calculate distance to another location
RESIDENTIAL_SALE
- Residential properties for saleRESIDENTIAL_RENT
- Residential properties for rentCOMMERCIAL_SALE
- Commercial properties for saleCOMMERCIAL_RENT
- Commercial properties for rentSHARING
- Room sharingSTUDENT_ACCOMMODATION
- Student accommodationNEW_HOMES
- New homes
HOUSE
- HousesDETACHED_HOUSE
- Detached housesSEMI_DETACHED_HOUSE
- Semi-detached housesTERRACED_HOUSE
- Terraced housesAPARTMENT
- ApartmentsSTUDIO_APARTMENT
- Studio apartmentsOFFICE_SPACE
- Office spacesRETAIL_UNIT
- Retail units- And many more...
PARKING
- Parking availableINTERNET
- Internet includedWASHING_MACHINE
- Washing machineDISHWASHER
- DishwasherCENTRAL_HEATING
- Central heating- And many more...
import { Daft, SearchType, PropertyType, Location } from "daftlistings-ts";
const daft = new Daft();
daft.setSearchType(SearchType.RESIDENTIAL_RENT);
daft.setPropertyType(PropertyType.APARTMENT);
daft.setMinBeds(2);
daft.setMaxBeds(3);
daft.setMinPrice(1000);
daft.setMaxPrice(2000);
daft.setLocation(Location.DUBLIN_2);
const listings = await daft.search();
import { Daft, SearchType, PropertyType, Facility } from "daftlistings-ts";
const daft = new Daft();
daft.setSearchType(SearchType.COMMERCIAL_RENT);
daft.setPropertyType(PropertyType.OFFICE_SPACE);
daft.setMinFloorSize(100);
daft.setMaxFloorSize(500);
daft.setFacility(Facility.PARKING);
daft.setFacility(Facility.MEETING_ROOMS);
const listings = await daft.search();
import { Daft, SearchType, SuitableFor, Facility } from "daftlistings-ts";
const daft = new Daft();
daft.setSearchType(SearchType.STUDENT_ACCOMMODATION);
daft.setSuitability(SuitableFor.FEMALE);
daft.setFacility(Facility.INTERNET);
daft.setFacility(Facility.ENSUITE);
const listings = await daft.search();
const listing1 = listings[0];
const listing2 = listings[1];
// Calculate distance between two listings
const distance = listing1.distanceTo(listing2);
console.log(`Distance: ${distance.toFixed(2)} km`);
// Calculate distance to coordinates
const distanceToCoords = listing1.distanceTo([53.3498, -6.2603]); // Dublin city center
console.log(
`Distance to Dublin city center: ${distanceToCoords.toFixed(2)} km`
);
The library provides custom error types for better error handling:
import { DaftError, ValidationError, NetworkError } from "daftlistings-ts";
try {
const listings = await daft.search();
} catch (error) {
if (error instanceof ValidationError) {
console.error("Validation error:", error.message);
} else if (error instanceof NetworkError) {
console.error("Network error:", error.message);
} else if (error instanceof DaftError) {
console.error("Daft error:", error.message);
} else {
console.error("Unknown error:", error);
}
}
npm run build
npm test
npm run lint
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
This TypeScript library is based on the original Python daftlistings library by Anthony Bloomer.