Initial Marktplaats SDK scaffold

Clone the twdehands SDK into mrktplaats and retarget naming and defaults for app.marktplaats.nl while keeping the same request/response bodies and endpoint behavior.
This commit is contained in:
2026-04-15 23:45:49 +02:00
commit 25410749db
27 changed files with 3481 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
package mrktplaats
import (
"context"
"fmt"
"net/url"
)
// RelevantService retrieves similar/related listings.
type RelevantService struct {
t *transport
}
// SimilarAdCore is the ad core from the older API3 format (snake_case).
type SimilarAdCore struct {
ID string `json:"id"`
Title string `json:"title"`
Picture DiscoveryPicture `json:"picture"`
Price DiscoveryPrice `json:"price"`
}
// SimilarItem is a related listing.
type SimilarItem struct {
AdCore SimilarAdCore `json:"ad_core"`
PageLocation string `json:"page_location"`
}
// SimilarAdsResponse contains similar listings.
type SimilarAdsResponse struct {
Items []SimilarItem `json:"items"`
ResultType string `json:"result_type"`
}
// Get returns similar/related listings for a given listing.
func (s *RelevantService) Get(ctx context.Context, listingID string, sellerID string, categoryID int) (*SimilarAdsResponse, error) {
path := fmt.Sprintf("/api3/ads/relevant/%s.json", listingID)
params := url.Values{}
if sellerID != "" {
params.Set("seller_id", sellerID)
}
params.Set("category_id", fmt.Sprintf("%d", categoryID))
var resp SimilarAdsResponse
if err := s.t.get(ctx, path, params, &resp); err != nil {
return nil, err
}
return &resp, nil
}