craigslist

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 10 Imported by: 0

README

Craigslist

Go Report Card Godoc Releases LICENSE

Package craigslist is an unofficial implementation of the Craigslist REST API used by their mobile applications.

This library is for educational use only and is provided "as-is". This library is not associated with or endorsed by Craigslist.

Documentation

Overview

Package craigslist is an unofficial implementation of the Craigslist REST API used by their mobile applications.

This library is for educational use only and is provided "as-is". This library is not associated with or endorsed by Craigslist.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocationParams

type LocationParams struct {
	AreaID         int
	Latitude       float32
	Longitude      float32
	SearchDistance int
}

LocationParams describes parameters for specifying the location for a craigslist query

type Posting

type Posting struct {
	PostedDate   int64              `json:"postedDate"`
	SeeMyOther   int                `json:"seeMyOther"`
	URL          string             `json:"url"`
	Location     PostingLocation    `json:"location"`
	CategoryID   int                `json:"categoryId"`
	UpdatedDate  int64              `json:"updatedDate"`
	Attributes   []PostingAttribute `json:"attributes"`
	Category     string             `json:"category"`
	Body         string             `json:"body"`
	PostingID    int64              `json:"postingId"`
	Section      string             `json:"section"`
	CategoryAbbr string             `json:"categoryAbbr"`
	Title        string             `json:"title"`
	Images       []string           `json:"images"`
	Price        float64            `json:"price"`
}

Posting describes the structure for a single post

func GetPosting

func GetPosting(id int, categoryAbbr string, location PostingLocation) (*Posting, error)

GetPosting get the full posting details for the given post. It's recommended that you don't call this method directly, but rather call 'Posting()' on a `craigslist.Result` object instead.

type PostingAttribute

type PostingAttribute struct {
	SpecialType string `json:"specialType"`
	Label       string `json:"label"`
	Value       string `json:"value"`
}

PostingAttribute describes the structure for a single attribute on a posting

type PostingLocation

type PostingLocation struct {
	AreaID      int     `json:"areaId"`
	Hostname    string  `json:"hostname"`
	Lat         float32 `json:"lat"`
	Lon         float32 `json:"lon"`
	SubareaAbbr string  `json:"subareaAbbr"`
}

PostingLocation describes the location for a craigslist post

type Result

type Result struct {
	CategoryAbbr string          `json:"categoryAbbr"`
	CategoryID   string          `json:"categoryId"`
	DedupeKey    string          `json:"dedupeKey"`
	Images       []string        `json:"images"`
	Location     PostingLocation `json:"location"`
	PostedDate   int             `json:"postedDate"`
	PostingID    int             `json:"postingId"`
	Price        int             `json:"price"`
	Title        string          `json:"title"`
}

Result describes a single craigslist post

func Search(category string, query string, location LocationParams) ([]Result, error)

Search will return an array of all postings for the given category. A query can be included to search for postings matching a specific query.

The category must be the 3-letter category code. See https://github.com/ecnepsnai/craigslist/blob/main/categories.md for a list of all possible categories. The query can be an empty string to list all recent posts for the category. The location must is used to refine the craigslist search to your specific area, and is required

Returns a slice of results, which are not as detailed as a full posting.

func (Result) ImageURLs

func (r Result) ImageURLs() []string

ImageURLs get an array of URLs that contain all images in this posting at or around 600x450

func (Result) Posting

func (r Result) Posting() (*Posting, error)

Posting get the full posting for the result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL