openalex-client
Version:
TypeScript SDK for OpenAlex academic database API
208 lines • 5.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SourcesService = void 0;
const base_1 = require("./base");
class SourcesService extends base_1.BaseService {
constructor() {
super(...arguments);
this.endpoint = "sources";
}
/**
* Get works published in a specific source
*/
async getWorks(sourceId, params) {
const cleanId = this.cleanId(sourceId);
const response = await this.client.get(`/sources/${cleanId}/works`, this.buildParams(params));
return response.data;
}
/**
* Get source by ISSN
*/
async getByIssn(issn, params) {
const filterParams = {
...params,
filter: { issn: issn },
};
const response = await this.list(filterParams);
if (response.results.length === 0) {
throw new Error(`No source found with ISSN: ${issn}`);
}
return response.results[0];
}
/**
* Search sources by multiple ISSNs
*/
async getByIssns(issns, params) {
const filterParams = {
...params,
filter: {
...params?.filter,
issn: issns,
},
};
return this.list(filterParams);
}
/**
* Get open access sources
*/
async getOpenAccess(params) {
const filterParams = {
...params,
filter: {
...params?.filter,
is_oa: true,
},
};
return this.list(filterParams);
}
/**
* Get sources in DOAJ (Directory of Open Access Journals)
*/
async getDoajSources(params) {
const filterParams = {
...params,
filter: {
...params?.filter,
is_in_doaj: true,
},
};
return this.list(filterParams);
}
/**
* Get sources by publisher
*/
async getByPublisher(publisher, params) {
const filterParams = {
...params,
filter: {
...params?.filter,
publisher: publisher,
},
};
return this.list(filterParams);
}
/**
* Get sources by type (journal, repository, etc.)
*/
async getByType(type, params) {
const filterParams = {
...params,
filter: {
...params?.filter,
type: type,
},
};
return this.list(filterParams);
}
/**
* Get journal sources
*/
async getJournals(params) {
return this.getByType("journal", params);
}
/**
* Get repository sources
*/
async getRepositories(params) {
return this.getByType("repository", params);
}
/**
* Get conference sources
*/
async getConferences(params) {
return this.getByType("conference", params);
}
/**
* Get book series sources
*/
async getBookSeries(params) {
return this.getByType("book-series", params);
}
/**
* Get highly cited sources
*/
async getHighlyCited(params) {
return this.list({
...params,
sort: "cited_by_count:desc",
});
}
/**
* Get sources with most works
*/
async getMostProlific(params) {
return this.list({
...params,
sort: "works_count:desc",
});
}
/**
* Get sources by country
*/
async getByCountry(countryCode, params) {
const filterParams = {
...params,
filter: {
...params?.filter,
country_code: countryCode.toUpperCase(),
},
};
return this.list(filterParams);
}
/**
* Get sources by concept (subject area)
*/
async getByConcept(conceptId, params) {
const cleanId = this.cleanId(conceptId);
const filterParams = {
...params,
filter: {
...params?.filter,
"x_concepts.id": cleanId,
},
};
return this.list(filterParams);
}
/**
* Get sources with APC (Article Processing Charges) information
*/
async getWithApc(params) {
const filterParams = {
...params,
filter: {
...params?.filter,
apc_usd: ">0",
},
};
return this.list(filterParams);
}
/**
* Get sources by APC price range
*/
async getByApcRange(minUsd, maxUsd, params) {
const filterParams = {
...params,
filter: {
...params?.filter,
apc_usd: `${minUsd}-${maxUsd}`,
},
};
return this.list(filterParams);
}
/**
* Get sources by host organization
*/
async getByHostOrganization(organizationId, params) {
const cleanId = this.cleanId(organizationId);
const filterParams = {
...params,
filter: {
...params?.filter,
host_organization: cleanId,
},
};
return this.list(filterParams);
}
}
exports.SourcesService = SourcesService;
//# sourceMappingURL=sources.js.map